You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/iot/azure-iot/aggregation.md
+34-5Lines changed: 34 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -177,8 +177,37 @@ Now that your Azure Function is fully tested and ready, it's time to deploy it t
177
177

178
178
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.
179
179
4. Open the Azure Portal, and go to your function app (in this example, "IoTTemperatureAlertFunc"). You will see the deployed functions:
180
-

181
-
182
-
## Configure Functions
183
-
184
-
## Testing
180
+

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
+

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
+

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
+

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