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: articles/digital-twins/how-to-create-routes.md
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ titleSuffix: Azure Digital Twins
4
4
description: Learn how to set up event routes and event filters to Azure Digital Twins endpoints
5
5
author: baanders
6
6
ms.author: baanders
7
-
ms.date: 1/3/2024
7
+
ms.date: 04/17/2025
8
8
ms.topic: how-to
9
9
ms.service: azure-digital-twins
10
10
ms.custom: devx-track-azurecli
@@ -18,57 +18,57 @@ Routing [event notifications](concepts-event-notifications.md) from Azure Digita
18
18
19
19
## Prerequisites
20
20
21
-
* You'll need an Azure account, which [can be set up for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F)
22
-
* You'll need an Azure Digital Twins instance in your Azure subscription. If you don't have an instance already, you can create one using the steps in [Set up an instance and authentication](how-to-set-up-instance-portal.md). Have the following values from setup handy to use later in this article:
21
+
* You need an Azure account, which [can be set up for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F)
22
+
* You need an Azure Digital Twins instance in your Azure subscription. If you don't have an instance already, you can create one using the steps in [Set up an instance and authentication](how-to-set-up-instance-portal.md). Have the following values from setup handy to use later in this article:
23
23
- Instance name
24
24
- Resource group
25
25
26
26
You can find these details in the [Azure portal](https://portal.azure.com) after setting up your instance.
27
27
28
28
:::image type="content" source="media/includes/instance-details.png" alt-text="Screenshot of the Overview page for an Azure Digital Twins instance in the Azure portal. The name and resource group are highlighted." lightbox="media/includes/instance-details.png":::
29
29
30
-
* Create an endpoint using the instructions in [Create endpoints](how-to-create-endpoints.md). In this article, you'll create a route to send data to that endpoint.
30
+
* Create an endpoint using the instructions in [Create endpoints](how-to-create-endpoints.md). In this article, you create a route to send data to that endpoint.
31
31
32
-
Next, follow the instructions below if you intend to use the Azure CLI while following this guide.
32
+
Next, perform the following instructions if you intend to use the Azure CLI while following this guide.
After [creating an endpoint](how-to-create-endpoints.md), you'll need to define an *event route* to actually send data to the endpoint. These routes let developers wire up event flow, throughout the system and to downstream services. A single route can allow multiple notifications and event types to be selected. Read more about event routes in [Endpoints and event routes](concepts-route-events.md).
38
+
After [creating an endpoint](how-to-create-endpoints.md), you'll need to define an *event route* to actually send data to the endpoint. These routes let developers wire up event flow, throughout the system and to downstream services. A single route can allow multiple notifications and event types to be selected. For more information about event routes, see [Route Azure Digital Twins events](concepts-route-events.md).
39
39
40
40
>[!NOTE]
41
-
> Make sure you've created at least one endpoint as described in the [Prerequisites](#prerequisites) before you move on to creating a route.
41
+
> Make sure you created at least one endpoint as described in the [Prerequisites](#prerequisites) before you move on to creating a route.
42
42
>
43
-
>If you've only recently deployed your endpoints, validate that they're finished deploying before attempting to use them for a new event route. If route deployment fails because the endpoints aren't ready, wait a few minutes and try again.
43
+
>If you only recently deployed your endpoints, validate that they're finished deploying before attempting to use them for a new event route. If route deployment fails because the endpoints aren't ready, wait a few minutes and try again.
44
44
>
45
-
> If you are scripting this flow, you may want to account for this by building in 2-3 minutes of wait time for the endpoint service to finish deploying before moving on to route setup.
45
+
> If you're scripting this flow, you might want to account for deployment by building in 2-3 minutes of wait time for the endpoint service to finish deploying before moving on to route setup.
46
46
47
47
A route definition can contain these elements:
48
48
* The route name you want to use
49
49
* The name of the endpoint you want to use
50
50
* A filter that defines which events are sent to the endpoint
51
51
- To disable the route so that no events are sent, use a filter value of `false`
52
52
- To enable a route that has no specific filtering, use a filter value of `true`
53
-
- For details on any other type of filter, see the [Filter events](#filter-events) section below
53
+
- For details on any other type of filter, see the [Filter events](#filter-events) section
54
54
55
55
If there's no route name, no messages are routed outside of Azure Digital Twins.
56
56
If there's a route name and the filter is `true`, all messages are routed to the endpoint.
57
-
If there's a route name and a different filter is added, messages will be filtered based on the filter.
57
+
If there's a route name and a different filter is added, messages are filtered based on the filter.
58
58
59
-
Event routes can be created with the [Azure portal](https://portal.azure.com), [EventRoutes data plane APIs](/rest/api/digital-twins/dataplane/event-routes), or [az dt route CLI commands](/cli/azure/dt/route). The rest of this section walks through the creation process.
59
+
Event routes can be created with the [Azure portal](https://portal.azure.com), [Event Routes data plane APIs](/rest/api/digital-twins/dataplane/event-routes), or [az dt route CLI commands](/cli/azure/dt/route). The rest of this section walks through the creation process.
60
60
61
61
# [Portal](#tab/portal2)
62
62
63
-
To create an event route, go to the details page for your Azure Digital Twins instance in the [Azure portal](https://portal.azure.com) (you can find the instance by entering its name into the portal search bar).
63
+
To create an event route, go to the details page for your Azure Digital Twins instance in the [Azure portal](https://portal.azure.com). You can find the instance by entering its name into the portal search bar.
64
64
65
65
From the instance menu, select **Event routes**. Then from the **Event routes** page that follows, select **+ Create an event route**.
66
66
67
67
On the **Create an event route** page that opens up, choose at minimum:
68
68
* A name for your route in the **Name** field
69
69
* The **Endpoint** you want to use to create the route
70
70
71
-
For the route to be enabled, you must also **Add an event route filter** of at least `true`. (Leaving the default value of `false`will create the route, but no events will be sent to it.) To do so, toggle the switch for the **Advanced editor** to enable it, and write `true` in the **Filter** box.
71
+
For the route to be enabled, you must also **Add an event route filter** of at least `true`. (Leaving the default value of `false`creates the route, but no events are sent to it.) To do so, toggle the switch for the **Advanced editor** to enable it, and write `true` in the **Filter** box.
72
72
73
73
:::image type="content" source="media/how-to-create-routes/create-event-route-no-filter.png" alt-text="Screenshot of creating an event route for your instance in the Azure portal." lightbox="media/how-to-create-routes/create-event-route-no-filter.png":::
74
74
@@ -93,25 +93,25 @@ This section shows how to create an event route using the [.NET (C#) SDK](/dotne
93
93
94
94
### Event route sample SDK code
95
95
96
-
The following sample method shows how to create, list, and delete an event route with the C# SDK:
96
+
The following sample method shows how to create, list, and delete an event route with the .NET SDK:
As described above, routes have a filter field. If the filter value on your route is `false`, no events will be sent to your endpoint.
104
+
As described previously, routes have a filter field. If the filter value on your route is `false`, no events are sent to your endpoint.
105
105
106
-
After you've enabled a minimal filter of `true`, endpoints will receive different kinds of events from Azure Digital Twins:
106
+
After you enabled a minimal filter of `true`, endpoints will receive different kinds of events from Azure Digital Twins:
107
107
*[Telemetry fired by digital twins](concepts-event-notifications.md#digital-twin-telemetry-messages) using the Azure Digital Twins service API
108
108
* Twin property change notifications, fired on property changes for any twin in the Azure Digital Twins instance
109
109
* Life-cycle events, fired when twins or relationships are created or deleted
110
110
111
111
You can restrict the types of events being sent by defining a more-specific filter.
112
112
113
113
>[!NOTE]
114
-
> Filters are case-sensitive and need to match the payload case. For telemetry filters, this means that the casing needs to match the casing in the telemetry sent by the device.
114
+
> Filters are case-sensitive and need to match the payload case. For telemetry filters, the casing in the filter must match the casing in the telemetry sent by the device.
115
115
116
116
# [Portal](#tab/portal3)
117
117
@@ -125,7 +125,7 @@ To use the basic filters, expand the **Event types** option and select the check
125
125
126
126
:::image type="content" source="media/how-to-create-routes/create-event-route-filter-basic-1.png" alt-text="Screenshot of creating an event route with a basic filter in the Azure portal, highlighting the checkboxes of the events." lightbox="media/how-to-create-routes/create-event-route-filter-basic-1-large.png":::
127
127
128
-
Doing so will autopopulate the filter text box with the text of the filter you've selected:
128
+
Doing so autopopulates the filter text box with the text of the filter you selected:
129
129
130
130
:::image type="content" source="media/how-to-create-routes/create-event-route-filter-basic-2.png" alt-text="Screenshot of creating an event route with a basic filter in the Azure portal, highlighting the autopopulated filter text after selecting the events." lightbox="media/how-to-create-routes/create-event-route-filter-basic-2-large.png":::
131
131
@@ -154,16 +154,16 @@ Here are the supported route filters.
154
154
| True / False | Allows creating a route with no filtering, or disabling a route so no events are sent |`<true/false>`|`true` = route is enabled with no filtering <br> `false` = route is disabled |
155
155
| Type | The [type of event](concepts-route-events.md#types-of-event-messages) flowing through your digital twin instance |`type = '<event-type>'`| Here are the possible event type values: <br>`Microsoft.DigitalTwins.Twin.Create` <br> `Microsoft.DigitalTwins.Twin.Delete` <br> `Microsoft.DigitalTwins.Twin.Update`<br>`Microsoft.DigitalTwins.Relationship.Create`<br>`Microsoft.DigitalTwins.Relationship.Update`<br> `Microsoft.DigitalTwins.Relationship.Delete` <br> `microsoft.iot.telemetry`|
156
156
| Source | Name of Azure Digital Twins instance |`source = '<host-name>'`| Here are the possible host name values: <br><br> For notifications: `<your-Digital-Twins-instance>.api.<your-region>.digitaltwins.azure.net` <br><br> For telemetry: `<your-Digital-Twins-instance>.api.<your-region>.digitaltwins.azure.net/<twin-ID>`|
157
-
| Subject | A description of the event in the context of the event source above |`subject = '<subject>'`| Here are the possible subject values: <br><br>For notifications: The subject is `<twin-ID>` <br> or a URI format for subjects, which are uniquely identified by multiple parts or IDs:<br>`<twin-ID>/relationships/<relationship-ID>`<br><br> For telemetry: The subject is the component path (if the telemetry is emitted from a twin component), such as `comp1.comp2`. If the telemetry isn't emitted from a component, then its subject field is empty. |
157
+
| Subject | A description of the event in the context of the event source |`subject = '<subject>'`| Here are the possible subject values: <br><br>For notifications: The subject is `<twin-ID>` <br> or a URI format for subjects, which are uniquely identified by multiple parts or IDs:<br>`<twin-ID>/relationships/<relationship-ID>`<br><br> For telemetry: The subject is the component path (if the telemetry is emitted from a twin component), such as `comp1.comp2`. If the telemetry isn't emitted from a component, then its subject field is empty. |
158
158
| Data schema | DTDL model ID |`dataschema = '<model-dtmi-ID>'`| For telemetry: The data schema is the model ID of the twin or the component that emits the telemetry. For example, `dtmi:example:com:floor4;2` <br><br>For notifications (create/delete): Data schema can be accessed in the notification body at `$body.$metadata.$model`. <br><br>For notifications (update): Data schema can be accessed in the notification body at `$body.modelId`|
159
159
| Content type | Content type of data value |`datacontenttype = '<content-type>'`| The content type is `application/json`|
160
160
| Spec version | The version of the event schema you're using |`specversion = '<version>'`| The version must be `1.0`. This value indicates the CloudEvents schema version 1.0 |
161
161
| Notification body | Reference any property in the `data` field of a notification |`$body.<property>`| See [Event notifications](concepts-event-notifications.md) for examples of notifications. Any property in the `data` field can be referenced using `$body`|
162
162
163
163
>[!NOTE]
164
-
> Azure Digital Twins currently doesn't support filtering events based on fields within an array. This includes filtering on properties within a `patch` section of a [digital twin change notification](concepts-event-notifications.md#digital-twin-change-notifications).
164
+
> Azure Digital Twins currently doesn't support filtering events based on fields within an array. This limitation includes filtering on properties within a `patch` section of a [digital twin change notification](concepts-event-notifications.md#digital-twin-change-notifications).
165
165
166
-
The following data types are supported as values returned by references to the data above:
166
+
The following data types are supported as values returned by references to the previous data:
167
167
168
168
| Data type | Example |
169
169
|-|-|-|
@@ -188,13 +188,13 @@ The following functions are supported when defining route filters:
188
188
|ENDS_WITH(x,y) | Returns true if the value `x` ends with the string `y`.|`ENDS_WITH($body.$metadata.$model, 'floor;1')`|
189
189
|CONTAINS(x,y)| Returns true if the value `x` contains the string `y`.|`CONTAINS(subject, '<twin-ID>')`|
190
190
191
-
When you implement or update a filter, the change may take a few minutes to be reflected in the data pipeline.
191
+
When you implement or update a filter, the change might take a few minutes to be reflected in the data pipeline.
192
192
193
193
## Monitor event routes
194
194
195
195
Routing metrics such as count, latency, and failure rate can be viewed in the [Azure portal](https://portal.azure.com/).
196
196
197
-
For information about viewing and managing metrics with Azure Monitor, see [Get started with metrics explorer](/azure/azure-monitor/essentials/metrics-getting-started). For a full list of routing metrics available for Azure Digital Twins, see [Azure Digital Twins routing metrics](how-to-monitor.md#routing-metrics).
197
+
For information about viewing and managing metrics with Azure Monitor, see [Analyze metrics with Azure Monitor metrics explorer](/azure/azure-monitor/essentials/metrics-getting-started). For a full list of routing metrics available for Azure Digital Twins, see [Routing metrics](how-to-monitor.md#routing-metrics).
0 commit comments