Skip to content

Commit cc7647e

Browse files
committed
WIP
1 parent e59feb1 commit cc7647e

4 files changed

Lines changed: 34 additions & 5 deletions

File tree

275 KB
Loading
293 KB
Loading
58.8 KB
Loading

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

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,37 @@ Now that your Azure Function is fully tested and ready, it's time to deploy it t
177177
![img39 alt-text#center](Figures/39.png)
178178
3. Wait for the deployment to complete. This process typically takes a few moments. Once deployed, your Azure Function is hosted in Azure and ready for use.
179179
4. Open the Azure Portal, and go to your function app (in this example, "IoTTemperatureAlertFunc"). You will see the deployed functions:
180-
![img34 alt-text#center](Figures/40.png)
181-
182-
## Configure Functions
183-
184-
## Testing
180+
![img40 alt-text#center](Figures/40.png)
181+
182+
## Configure Function App Settings
183+
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.
184+
185+
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.
186+
187+
Follow these steps to configure the Cosmos DB connection string
188+
1. In the Azure Portal navigate to Azure Function App.
189+
2. Click Environmental variables (under Settings)
190+
3. Click the + Add button
191+
4. Enter the name you used in your code (e.g., armiotcosmosdb_DOCUMENTDB).
192+
5. Paste the Cosmos DB connection string into the Value field:
193+
![img41 alt-text#center](Figures/41.png)
194+
6. Click Apply to add the setting.
195+
7. Press Apply at the bottom to apply changes. Then, confirm to save changes
196+
197+
## Testing the Azure Function
198+
Once you've configured the connection string, test your deployed Azure Function as follows:
199+
1. Return to the Overview page of your Azure Function App.
200+
2. Click on your HTTP-triggered function (GetAverageTemperature).
201+
3. Click Get function URL and copy the displayed URL (under default):
202+
![img42 alt-text#center](Figures/42.png)
203+
4. Open this URL in your web browser.
204+
5. Start your IoT simulator to begin streaming telemetry data to Cosmos DB.
205+
6. Refresh or access the function URL again, and you should see the calculated average temperature displayed:
206+
![img43 alt-text#center](Figures/43.png)
207+
208+
This confirms your Azure Function successfully connects to Cosmos DB, retrieves real-time data, and calculates the average temperature as intended
209+
210+
## Summary and 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. 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.
212+
213+
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.

0 commit comments

Comments
 (0)