Skip to content

Commit c598d9b

Browse files
Merge pull request #250481 from stevemunk/tutorial-iot-hub-maps-function
Updates to Tutorial: Implement IoT spatial analytics by using Azure Maps
2 parents 035d50b + cd37bdb commit c598d9b

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed
160 KB
Loading
48.5 KB
Loading
14.6 KB
Loading
92.9 KB
Loading

articles/azure-maps/tutorial-iot-hub-maps.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ In this tutorial you will:
2323
> [!div class="checklist"]
2424
>
2525
> * Create an Azure storage account to log car tracking data.
26-
> * Upload a geofence to the Azure Maps Data service by using the Data Upload API.
26+
> * Upload a geofence to the Azure Maps Data service using the Data Upload API.
2727
> * Create a hub in Azure IoT Hub, and register a device.
2828
> * Create a function in Azure Functions, implementing business logic based on Azure Maps spatial analytics.
2929
> * Subscribe to IoT device telemetry events from the Azure function via Azure Event Grid.
@@ -38,6 +38,9 @@ If you don't have an Azure subscription, create a [free account] before you begi
3838
* A [resource group]
3939
* The [rentalCarSimulation] C# project
4040

41+
> [!TIP]
42+
> You can download the entire [rentalCarSimulation] C# project from GitHub as a single ZIP file by going to [the root of the sample] and selecting the green **<> Code** button, then **Download ZIP**.
43+
4144
This tutorial uses the [Postman] application, but you can choose a different API development environment.
4245

4346
>[!IMPORTANT]
@@ -108,7 +111,7 @@ When you successfully create your storage account, you then need to create a con
108111

109112
:::image type="content" source="./media/tutorial-iot-hub-maps/container-new.png" alt-text="Screenshot of create a blob container.":::
110113

111-
3. Go to the **Access keys** pane in your storage account, and copy the **Storage account name** and the **Key** value in the **key1** section. You need both of these values in the "Create an Azure Function and add an Event Grid subscription" section.
114+
3. Go to the **Access keys** pane in your storage account, and copy the **Storage account name** and the **Key** value in the **key1** section. You need both of these values in the [Create a function and add an Event Grid subscription] section.
112115

113116
:::image type="content" source="./media/tutorial-iot-hub-maps/access-keys.png" alt-text="Screenshot of copy storage account name and key.":::
114117

@@ -128,7 +131,7 @@ Follow these steps to upload the geofence by using the Azure Maps Data Upload AP
128131
129132
In the URL path, the `geojson` value against the `dataFormat` parameter represents the format of the data being uploaded.
130133
131-
3. Select **Body** > **raw** for the input format, and choose **JSON** from the drop-down list. [Open the JSON data file], and copy the JSON into the body section. Select **Send**.
134+
3. Select **Body** > **raw** for the input format, and choose **JSON** from the drop-down list. [Open the JSON data file], and copy the JSON into the body section.
132135
133136
4. Select **Send** and wait for the request to process. After the request completes, go to the **Headers** tab of the response. Copy the value of the **Operation-Location** key, which is the `status URL`.
134137
@@ -168,20 +171,24 @@ Now, set up your Azure function.
168171

169172
1. In the Azure portal dashboard, select **Create a resource**. Type **Function App** in the search text box. Select **Function App** > **Create**.
170173

171-
1. On the **Function App** creation page, name your function app. Under **Resource Group**, select **ContosoRental** from the drop-down list. Select **.NET** as the **Runtime Stack**. Select **3.1** as the **Version**. At the bottom of the page, select **Next: Hosting >**.
174+
1. On the **Function App** creation page, name your function app. Under **Resource Group**, select **ContosoRental** from the drop-down list. Select **.NET** as the **Runtime Stack**. At the bottom of the page, select **Next: Storage >**.
172175

173176
:::image type="content" source="./media/tutorial-iot-hub-maps/rental-app.png" alt-text="Screenshot of create a function app.":::
174177

175178
1. For **Storage account**, select the storage account you created in [Create an Azure storage account]. Select **Review + create**.
176179

177180
1. Review the function app details, and select **Create**.
178181

179-
1. After the app is created, you add a function to it. Go to the function app. Select the **Functions** pane. At the top of the page, select **+ Add**. The function template panel appears. Scroll down the panel, and select **Azure Event Grid trigger**.
182+
1. After the app is created, you add a function to it. Go to the function app. Select the **Create in Azure Portal** button.
180183

181184
>[!IMPORTANT]
182-
> The **Azure Event Hub Trigger** and the **Azure Event Grid Trigger** templates have similar names. Make sure you select the **Azure Event Grid Trigger** template.
185+
> The **Azure Event ***Hub*** Trigger** and the **Azure Event ***Grid*** Trigger** templates have similar names. Make sure you select the **Azure Event ***Grid*** Trigger** template.
186+
187+
:::image type="content" source="./media/tutorial-iot-hub-maps/function-create.png" alt-text="Screenshot of create a function in Azure Portal.":::
188+
189+
1. The **Create function** panel appears. Scroll down the **Select a template** panel, and select **Azure Event Grid trigger** then select the **Create** button.
183190

184-
:::image type="content" source="./media/tutorial-iot-hub-maps/function-create.png" alt-text="Screenshot of create a function.":::
191+
:::image type="content" source="./media/tutorial-iot-hub-maps/azure-event-grid-trigger.png" alt-text="Screenshot of create a function.":::
185192

186193
1. Give the function a name. In this tutorial, use the name *GetGeoFunction*, but in general you can use any name you like. Select **Create function**.
187194

@@ -225,13 +232,13 @@ In your example scenario, you only want to receive messages when the rental car
225232
226233
## Send telemetry data to IoT Hub
227234

228-
When your Azure function is running, you can now send telemetry data to the IoT hub, which routes it to Event Grid. Use a C# application to simulate location data for an in-vehicle device of a rental car. To run the application, you need [.NET Core SDK 3.1] on your development computer. Follow these steps to send simulated telemetry data to the IoT hub:
235+
When your Azure function is running, you can now send telemetry data to the IoT hub, which routes it to Event Grid. Use a C# application to simulate location data for an in-vehicle device of a rental car. To run the application, you need [.NET SDK 6.0] on your development computer. Follow these steps to send simulated telemetry data to the IoT hub:
229236

230237
1. If you haven't done so already, download the [rentalCarSimulation] C# project.
231238

232239
2. Open the `simulatedCar.cs` file in a text editor of your choice, and replace the value of the `connectionString` with the one you saved when you registered the device. Save changes to the file.
233240

234-
3. Make sure you have .NET Core installed on your machine. In your local terminal window, go to the root folder of the C# project and run the following command to install the required packages for simulated device application:
241+
3. Make sure you have the ASP.NET Core Runtime installed on your machine. In your local terminal window, go to the root folder of the C# project and run the following command to install the required packages for simulated device application:
235242

236243
```cmd/sh
237244
dotnet restore
@@ -283,7 +290,7 @@ To learn more about how to send device-to-cloud telemetry, and the other way aro
283290
> [!div class="nextstepaction"]
284291
> [Send telemetry from a device]
285292
286-
[.NET Core SDK 3.1]: https://dotnet.microsoft.com/download/dotnet/3.1
293+
[.NET SDK 6.0]: https://dotnet.microsoft.com/download/dotnet/6.0
287294
[Azure certified devices]: https://devicecatalog.azure.com/
288295
[Azure Functions]: ../azure-functions/functions-overview.md
289296
[Azure Maps account]: quick-demo-map-app.md#create-an-azure-maps-account
@@ -292,6 +299,7 @@ To learn more about how to send device-to-cloud telemetry, and the other way aro
292299
[create a storage account]: ../storage/common/storage-account-create.md?tabs=azure-portal
293300
[Create an Azure storage account]: #create-an-azure-storage-account
294301
[create an IoT hub]: ../iot-develop/quickstart-send-telemetry-iot-hub.md?pivots=programming-language-csharp#create-an-iot-hub
302+
[Create a function and add an Event Grid subscription]: #create-a-function-and-add-an-event-grid-subscription
295303
[free account]: https://azure.microsoft.com/free/
296304
[general-purpose v2 storage account]: ../storage/common/storage-account-overview.md
297305
[Get Geofence]: /rest/api/maps/spatial/getgeofence
@@ -304,6 +312,7 @@ To learn more about how to send device-to-cloud telemetry, and the other way aro
304312
[register a new device in the IoT hub]: ../iot-hub/iot-hub-create-through-portal.md#register-a-new-device-in-the-iot-hub
305313
[rentalCarSimulation]: https://github.com/Azure-Samples/iothub-to-azure-maps-geofencing/tree/master/src/rentalCarSimulation
306314
[resource group]: ../azure-resource-manager/management/manage-resource-groups-portal.md#create-resource-groups
315+
[the root of the sample]: https://github.com/Azure-Samples/iothub-to-azure-maps-geofencing
307316
[Search Address Reverse]: /rest/api/maps/search/getsearchaddressreverse
308317
[Send telemetry from a device]: ../iot-develop/quickstart-send-telemetry-iot-hub.md?pivots=programming-language-csharp
309318
[Spatial Geofence Get API]: /rest/api/maps/spatial/getgeofence

0 commit comments

Comments
 (0)