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
# Use Azure Digital Twins to update an Azure Maps indoor map
19
+
# Integrate Azure Digital Twins data into an Azure Maps indoor map
19
20
20
-
This article walks through the steps required to use Azure Digital Twins data to update information displayed on an *indoor map*using[Azure Maps](../azure-maps/about-azure-maps.md). Azure Digital Twins stores a graph of your IoT device relationships and routes telemetry to different endpoints, making it the perfect service for updating informational overlays on maps.
21
+
This article shows how to use Azure Digital Twins data to update information displayed on an *indoor map*from[Azure Maps](../azure-maps/about-azure-maps.md). Because Azure Digital Twins stores a graph of your IoT device relationships and routes telemetry to different endpoints, it's a great service for updating informational overlays on maps.
21
22
22
-
This guide will cover:
23
+
This guide covers the following information:
23
24
24
25
1. Configuring your Azure Digital Twins instance to send twin update events to a function in [Azure Functions](../azure-functions/functions-overview.md).
25
26
2. Creating a function to update an Azure Maps indoor maps feature stateset.
26
27
3. Storing your maps ID and feature stateset ID in the Azure Digital Twins graph.
27
28
29
+
## Get started
30
+
31
+
This section sets additional context for the information in this article.
32
+
28
33
### Prerequisites
29
34
30
35
Before proceeding with this article, start by setting up your individual Azure Digital Twins and Azure Maps resources.
@@ -41,16 +46,14 @@ The image below illustrates where the indoor maps integration elements in this t
41
46
42
47
:::image type="content" source="media/how-to-integrate-maps/maps-integration-topology.png" alt-text="Diagram of Azure services in an end-to-end scenario, highlighting the Indoor Maps Integration piece." lightbox="media/how-to-integrate-maps/maps-integration-topology.png":::
43
48
44
-
## Create a function to update a map when twins update
45
-
46
-
First, you'll create a route in Azure Digital Twins to forward all twin update events to an Event Grid topic. Then, you'll use a function to read those update messages and update a feature stateset in Azure Maps.
49
+
## Route twin update notifications from Azure Digital Twins
47
50
48
-
## Create a route and filter to twin update notifications
49
-
50
-
Azure Digital Twins instances can emit twin update events whenever a twin's state is updated. The Azure Digital Twins [Connect an end-to-end solution](./tutorial-end-to-end.md) linked above walks through a scenario where a thermometer is used to update a temperature attribute attached to a room's twin. You'll be extending that solution by subscribing to update notifications for twins, and using that information to update your maps.
51
+
Azure Digital Twins instances can emit twin update events whenever a twin's state is updated. The Azure Digital Twins [Connect an end-to-end solution](./tutorial-end-to-end.md) linked above walks through a scenario where a thermometer is used to update a temperature attribute attached to a room's twin. This tutorial extends that solution by subscribing an Azure function to update notifications from twins, and using that function to update your maps.
51
52
52
53
This pattern reads from the room twin directly, rather than the IoT device, which gives you the flexibility to change the underlying data source for temperature without needing to update your mapping logic. For example, you can add multiple thermometers or set this room to share a thermometer with another room, all without needing to update your map logic.
53
54
55
+
First, you'll create a route in Azure Digital Twins to forward all twin update events to an Event Grid topic.
56
+
54
57
1. Create an Event Grid topic, which will receive events from your Azure Digital Twins instance, using the CLI command below:
55
58
```azurecli-interactive
56
59
az eventgrid topic create --resource-group <your-resource-group-name> --name <your-topic-name> --location <region>
@@ -72,11 +75,11 @@ This pattern reads from the room twin directly, rather than the IoT device, whic
## Create an Azure function to receive events and update maps
76
79
77
-
You're going to create an Event Grid-triggered function inside your function app from the end-to-end tutorial ([Connect an end-to-end solution](./tutorial-end-to-end.md)). This function will unpack those notifications and send updates to an Azure Maps feature stateset to update the temperature of one room.
80
+
In this section, you'll create a function that listens for events sent to the Event Grid topic. The function will read those update notifications and send corresponding updates to an Azure Maps feature stateset, to update the temperature of one room.
78
81
79
-
See the following document for reference info: [Azure Event Grid trigger for Azure Functions](../azure-functions/functions-bindings-event-grid-trigger.md).
82
+
In the Azure Digital Twins tutorial [prerequisite](#prerequisites), you created a function app to store Azure functions Azure Digital Twins. Now, create a new [Event Grid-triggered Azure function](../azure-functions/functions-bindings-event-grid-trigger.md) inside the function app.
80
83
81
84
Replace the function code with the following code. It will filter out only updates to space twins, read the updated temperature, and send that information to Azure Maps.
82
85
@@ -89,7 +92,7 @@ az functionapp config appsettings set --name <your-function-app-name> --resource
89
92
az functionapp config appsettings set --name <your-function-app-name> --resource-group <your-resource-group> --settings "statesetID=<your-Azure-Maps-stateset-ID>"
90
93
```
91
94
92
-
### View live updates on your map
95
+
### View live updates in the map
93
96
94
97
To see live-updating temperature, follow the steps below:
95
98
@@ -103,7 +106,7 @@ Both samples send temperature in a compatible range, so you should see the color
103
106
104
107
:::image type="content" source="media/how-to-integrate-maps/maps-temperature-update.png" alt-text="Screenshot of an office map showing room 121 colored orange.":::
105
108
106
-
## Store your maps information in Azure Digital Twins
109
+
## Store map information in Azure Digital Twins
107
110
108
111
Now that you have a hardcoded solution to updating your maps information, you can use the Azure Digital Twins graph to store all of the information necessary for updating your indoor map. This information would include the stateset ID, maps subscription ID, and feature ID of each map and location respectively.
0 commit comments