Skip to content

Commit a1206d3

Browse files
authored
Merge pull request #104881 from farah-alyasari/iothub
iothub
2 parents bcf4b3a + 296c274 commit a1206d3

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed
-2.77 KB
Loading
38.4 KB
Loading

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ To implement business logic based on Azure Maps spatial analytics, we need to cr
113113

114114
### Create a storage account
115115

116-
To log event data, we'll create a general-purpose **v2storage** account in the "ContosoRental" resource group to store data as blobs. To create a storage account, follow instruction in [create a storage account](https://docs.microsoft.com/azure/storage/common/storage-quickstart-create-account?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&tabs=azure-portal). Next we'll need to create a container to store blobs. Follow the steps below to do so:
116+
To log event data, we'll create a general-purpose **v2storage** that provides access to all of the Azure Storage services: blobs, files, queues, tables, and disks. We'll need to place this storage account in the "ContosoRental" resource group to store data as blobs. To create a storage account, follow instruction in [create a storage account](https://docs.microsoft.com/azure/storage/common/storage-quickstart-create-account?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&tabs=azure-portal). Next we'll need to create a container to store blobs. Follow the steps below to do so:
117117

118-
1. In your storage account, navigate to Containers.
118+
1. In your "storage account - blob, file, table, queue", navigate to Containers.
119119

120120
![blobs](./media/tutorial-iot-hub-maps/blobs.png)
121121

@@ -152,6 +152,9 @@ In order to connect to the IoT Hub, a device must be registered. To register a d
152152

153153
![register-device](./media/tutorial-iot-hub-maps/register-device.png)
154154

155+
3. Save the **Primary Connection String** of your device to use it in a later step, in which you need to change a placeholder with this connection string.
156+
157+
![add-device](./media/tutorial-iot-hub-maps/connectionString.png)
155158

156159
## Upload geofence
157160

@@ -185,7 +188,7 @@ Open the Postman app and follow the steps below to upload the geofence using the
185188
https://atlas.microsoft.com/mapData/{uploadStatusId}/status?api-version=1.0
186189
```
187190

188-
6. Copy your status URI and append a `subscription-key` parameter to it with its value being your Azure Maps account subscription key. The status URI format should be like the one below:
191+
6. Copy your status URI and append a `subscription-key` parameter to it. Assign the value of your Azure Maps account subscription key to the `subscription-key` parameter. The status URI format should be like the one below, and `{Subscription-key}` replaced with your subscription key.
189192

190193
```HTTP
191194
https://atlas.microsoft.com/mapData/{uploadStatusId}/status?api-version=1.0&subscription-key={Subscription-key}
@@ -211,11 +214,11 @@ The logic we implement in the function is using the location data coming from th
211214

212215
All relevant event info is then kept in the blob store. Step 5 below points to the executable code implementing such logic. Follow the steps below to create an Azure Function that sends data logs to the blob container in the blob storage account and add an Event Grid subscription to it.
213216

214-
1. In the Azure portal dashboard, select create a resource. Select **Compute** from the list of available resource types and then select **Function APP**.
217+
1. In the Azure portal dashboard, select create a resource. Select **Compute** from the list of available resource types and then select **Function App**.
215218

216219
![create-resource](./media/tutorial-iot-hub-maps/create-resource.png)
217220

218-
2. On the **Function App** creation page, name your function app. Under **Resource Group**, select **Use existing**, and select "ContosoRental" from the drop-down list. Select ".NET Core" as the Runtime Stack. Under **Storage**, select **Use existing**, select "contosorentaldata" from the drop-down list, and then select **Review+Create**.
221+
2. On the **Function App** creation page, name your function app. Under **Resource Group**, select **Use existing**, and select "ContosoRental" from the drop-down list. Select ".NET Core" as the Runtime Stack. Under **Hosting**, for **Storage account**, select the storage account name from a prior step. In our prior step, we named the storage account **v2storage**. Then, select **Review+Create**.
219222

220223
![create-app](./media/tutorial-iot-hub-maps/rental-app.png)
221224

@@ -230,10 +233,12 @@ All relevant event info is then kept in the blob store. Step 5 below points to t
230233
5. Select the template with an **Azure Event Grid Trigger**. Install extensions if prompted, name the function, and select **Create**.
231234

232235
![function-template](./media/tutorial-iot-hub-maps/eventgrid-funct.png)
236+
237+
The **Azure Event Hub Trigger** and the **Azure Event Grid Trigger** have similar icons. Make sure you select the **Azure Event Grid Trigger**.
233238

234-
6. Copy the [c# code](https://github.com/Azure-Samples/iothub-to-azure-maps-geofencing/blob/master/src/Azure%20Function/run.csx) into your function and click **Save**.
239+
6. Copy the [C# code](https://github.com/Azure-Samples/iothub-to-azure-maps-geofencing/blob/master/src/Azure%20Function/run.csx) into your function.
235240

236-
7. In the c# script, replace the following parameters:
241+
7. In the C# script, replace the following parameters. Click **Save**. Don't click **Run** yet
237242
* Replace the **SUBSCRIPTION_KEY** with your Azure Maps account primary subscription key.
238243
* Replace the **UDID** with the udId of the geofence you uploaded,
239244
* The **CreateBlobAsync** function in the script creates a blob per event in the data storage account. Replace the **ACCESS_KEY**, **ACCOUNT_NAME**, and **STORAGE_CONTAINER_NAME** with your storage account's access key, account name, and data storage container.
@@ -242,7 +247,7 @@ All relevant event info is then kept in the blob store. Step 5 below points to t
242247

243248
![add-event-grid](./media/tutorial-iot-hub-maps/add-egs.png)
244249

245-
11. Fill out subscription details, under **EVENT SUBSCRIPTION DETAILS** name your subscription and for Event Schema choose "Event Grid Schema". Under **TOPIC DETAILS** select "Azure IoT Hub Accounts" as Topic type. Choose the same subscription you used for creating the resource group, select "ContosoRental" as the "Resource Group". Choose the IoT Hub you created as a "Resource". Pick **Device Telemetry** as Event Type. After choosing these options, you'll see the "Topic Type" change to "IoT Hub" automatically.
250+
11. Fill out subscription details, under **EVENT SUBSCRIPTION DETAILS** name your event subscription. For Event Schema choose "Event Grid Schema". Under **TOPIC DETAILS** select "Azure IoT Hub Accounts" as Topic type. Choose the same subscription you used for creating the resource group, select "ContosoRental" as the "Resource Group". Choose the IoT Hub you created as a "Resource". Pick **Device Telemetry** as Event Type. After choosing these options, you'll see the "Topic Type" change to "IoT Hub" automatically.
246251

247252
![event-grid-subscription](./media/tutorial-iot-hub-maps/af-egs.png)
248253

@@ -260,9 +265,9 @@ In our example scenario, we want to filter out all messages where the rental veh
260265

261266
## Send telemetry data to IoT Hub
262267

263-
Once our Azure Function is up and running, we can now send telemetry data to the IoT Hub, which will route it to the Event Grid. Let's use a c# application to simulate location data for an in-vehicle device of a rental car. To run the application, you need the .NET Core SDK 2.1.0 or greater on your development machine. Follow the steps below to send simulated telemetry data to IoT Hub.
268+
Once our Azure Function is up and running, we can now send telemetry data to the IoT Hub, which will route it to the Event Grid. Let's use a C# application to simulate location data for an in-vehicle device of a rental car. To run the application, you need the .NET Core SDK 2.1.0 or greater on your development machine. Follow the steps below to send simulated telemetry data to IoT Hub.
264269

265-
1. Download the [rentalCarSimulation](https://github.com/Azure-Samples/iothub-to-azure-maps-geofencing/tree/master/src/rentalCarSimulation) c# project.
270+
1. Download the [rentalCarSimulation](https://github.com/Azure-Samples/iothub-to-azure-maps-geofencing/tree/master/src/rentalCarSimulation) C# project.
266271

267272
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 and save changes to the file.
268273

0 commit comments

Comments
 (0)