Skip to content

Commit 5661e42

Browse files
authored
Merge pull request #1857 from pareenaverma/uvision-review
Tech review of Azure IoT LP
2 parents 98fd0b5 + d50db3f commit 5661e42

File tree

8 files changed

+122
-133
lines changed

8 files changed

+122
-133
lines changed

content/learning-paths/iot/azure-iot/_index.md

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Creating IoT Solutions in Azure for Arm64-Powered Devices
2+
title: Create IoT Solutions in Azure for Arm Powered Devices
3+
4+
minutes_to_complete: 180
35

46
draft: true
57
cascade:
68
draft: true
79

8-
minutes_to_complete: 320
9-
1010
who_is_this_for: This is an advanced topic for software developers interested in learning how to build a comprehensive IoT solution in Azure that streams, stores, monitors, aggregates, and visualizes data from Arm64-powered IoT devices.
1111

1212
learning_objectives:
@@ -21,8 +21,6 @@ learning_objectives:
2121
prerequisites:
2222
- A machine that can run Python3, and Visual Studio Code.
2323
- Azure Account and Subscription.
24-
- Azure CLI (Command Line Interface).
25-
- Azure IoT SDK for Python.
2624

2725
author: Dawid Borycki
2826

@@ -37,13 +35,8 @@ operatingsystems:
3735
- Linux
3836
- macOS
3937
tools_software_languages:
40-
- Coding
38+
- Azure
4139
- VS Code
42-
shared_path: true
43-
shared_between:
44-
- servers-and-cloud-computing
45-
- laptops-and-desktops
46-
- mobile-graphics-and-gaming
4740

4841
further_reading:
4942
- resource:

content/learning-paths/iot/azure-iot/aggregation.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ weight: 8
77
layout: "learningpathall"
88
---
99

10-
## Objective
11-
In the previous section, you configured Azure Stream Analytics to securely store incoming IoT telemetry data in Azure Cosmos DB, making sensor data readily available for further processing. In this section, you’ll enhance your IoT solution by implementing real-time data aggregation capabilities using Azure Functions. Azure Functions is a powerful, event-driven, serverless compute service provided by Azure that allows you to execute custom code in response to scheduled events without managing infrastructure. You’ll create an Azure Function that periodically queries sensor data from Cosmos DB and computes aggregated metrics, such as average, minimum, and maximum values, enabling you to derive actionable insights and monitor sensor performance more effectively.
10+
In the previous section, you configured Azure Stream Analytics to securely store incoming IoT telemetry data in Azure Cosmos DB, making sensor data readily available for further processing. In this section, you will enhance your IoT solution by implementing real-time data aggregation capabilities using Azure Functions. Azure Functions is a powerful, event-driven, serverless compute service provided by Azure that allows you to execute custom code in response to scheduled events without managing infrastructure. You will create an Azure Function that periodically queries sensor data from Cosmos DB and computes aggregated metrics, such as average, minimum, and maximum values, enabling you to derive actionable insights and monitor sensor performance more effectively.
1211

1312
## Data Aggregation
1413
As your IoT solution matures, the volume of sensor data continuously captured and securely stored in Azure Cosmos DB grows rapidly. However, raw telemetry data alone may not effectively communicate actionable insights, especially when quick decision-making and proactive management are required. Transforming this raw sensor data into meaningful, summarized information becomes essential for efficient monitoring, accurate analysis, and rapid response.
@@ -18,9 +17,9 @@ Aggregating sensor readings into various metrics such as average, minimum, and m
1817
In this section, you will leverage Azure Functions to implement a data aggregation. This Azure Function will respond to the HTTP trigger, and return aggregated sensor data.
1918

2019
### Azure Function with HTTP Trigger
21-
Building upon the sensor data aggregation strategy, this section demonstrates how to implement a serverless Azure Function using an HTTP trigger to calculate real-time insights from sensor data stored in Azure Cosmos DB. Specifically, you’ll create an HTTP-triggered function that queries temperature readings from the past minute, computes the average temperature, and returns this aggregated value as a JSON response. This HTTP-triggered approach provides an on-demand method to access up-to-date metrics.
20+
Building upon the sensor data aggregation strategy, this section demonstrates how to implement a serverless Azure Function using an HTTP trigger to calculate real-time insights from sensor data stored in Azure Cosmos DB. Specifically, you will create an HTTP-triggered function that queries temperature readings from the past minute, computes the average temperature, and returns this aggregated value as a JSON response. This HTTP-triggered approach provides an on-demand method to access up-to-date metrics.
2221

23-
To implement this functionality open the function_app.py and modify it as follows:
22+
To implement this functionality open the `function_app.py` and modify it as follows:
2423
1. Add the following import statements:
2524
```python
2625
from azure.cosmos import CosmosClient
@@ -128,7 +127,7 @@ def get_average_temperature(req: func.HttpRequest) -> func.HttpResponse:
128127
)
129128
```
130129

131-
The GetAverageTemperature function is triggered by an HTTP GET request sent to the route /averagetemperature. Upon invocation, it first logs that a request has been received for calculating the average temperature based on data from the last minute.
130+
The `GetAverageTemperature` function is triggered by an HTTP GET request sent to the route /averagetemperature. Upon invocation, it first logs that a request has been received for calculating the average temperature based on data from the last minute.
132131

133132
The function then retrieves the Cosmos DB connection string from an environment variable. If the connection string is not available, the function logs an error and returns a 500 Internal Server Error response, indicating that essential configuration details are missing.
134133

@@ -142,7 +141,7 @@ When data points are available, the function computes the average temperature fr
142141

143142
Finally, if the average calculation succeeds, the function constructs a JSON response containing the calculated average temperature (rounded to two decimal places) along with a success message. It then sends this response back to the caller with a status code of 200 OK and the configured CORS header {"Access-Control-Allow-Origin": "*"}, which is required to ensure that the portal can successfully retrieve and display the data from the function.
144143

145-
Before running the function, dependencies need to be added and installed. Open the requirements.txt file and include the following lines:
144+
Before running the function, dependencies need to be added and installed. Open the `requirements.txt` file and include the following lines:
146145

147146
```json
148147
azure-cosmos
@@ -181,7 +180,7 @@ Now that your Azure Function is fully tested and ready, it's time to deploy it t
181180
![img40 alt-text#center](Figures/40.png)
182181

183182
## Configure Function App Settings
184-
We have just deployed the functions to Azure. Previously, when testing the functions locally, we used the local.settings.json file to store the Cosmos DB connection string. However, this local configuration file is not deployed to Azure. Therefore, we need to update the corresponding settings directly within the Azure portal.
183+
You have just deployed the functions to Azure. Previously, when testing the functions locally, you used the `local.settings.json` file to store the Cosmos DB connection string. However, this local configuration file is not deployed to Azure. Therefore, you need to update the corresponding settings directly within the Azure portal.
185184

186185
Azure Function App settings, which are also known as application settings or environment variables, are designed to securely store sensitive configuration information, such as database connection strings, API keys, and other confidential details. Storing the Cosmos DB connection string as an app setting in Azure ensures secure management of your database credentials, allowing your function to safely access Cosmos DB without exposing sensitive information within your source code.
187186

@@ -208,7 +207,7 @@ Once you've configured the connection string, test your deployed Azure Function
208207

209208
This confirms your Azure Function successfully connects to Cosmos DB, retrieves real-time data, and calculates the average temperature as intended
210209

211-
## Summary and next steps
212-
In this section, you created an HTTP-triggered Azure Function that retrieves and aggregates records from Cosmos DB. You then deployed your Azure Function to Azure, configured secure application settings to safely store the Cosmos DB connection string, and verified the functionality. You also learned that the local configuration file (local.settings.json) is not automatically deployed to Azure, making it necessary to manually set up these sensitive settings within the Azure portal. Securely managing these application settings in Azure ensures that your functions can reliably connect to Cosmos DB, facilitating the accurate retrieval and processing of IoT telemetry data.
210+
## Next Steps
211+
In this section, you created an HTTP-triggered Azure Function that retrieves and aggregates records from Cosmos DB. You then deployed your Azure Function to Azure, configured secure application settings to safely store the Cosmos DB connection string, and verified the functionality.
213212

214-
In the next step, you’ll create a static website that leverages this HTTP-triggered function to display the average temperature in a web-based portal, thus completing your IoT solution.
213+
In the next step, you will create a static website that leverages this HTTP-triggered function to display the average temperature in a web-based portal, thus completing your IoT solution.

0 commit comments

Comments
 (0)