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,59 +18,59 @@ 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).
40
+
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).
41
41
42
42
>[!NOTE]
43
-
> Make sure you've created at least one endpoint as described in the [Prerequisites](#prerequisites) before you move on to creating a route.
43
+
> Make sure you created at least one endpoint as described in the [Prerequisites](#prerequisites) before you move on to creating a route.
44
44
>
45
-
>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.
45
+
>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.
46
46
>
47
-
> 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.
47
+
> 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.
48
48
49
49
A route definition can contain these elements:
50
50
* The route name you want to use
51
51
* The name of the endpoint you want to use
52
52
* A filter that defines which events are sent to the endpoint
53
53
- To disable the route so that no events are sent, use a filter value of `false`
54
54
- To enable a route that has no specific filtering, use a filter value of `true`
55
-
- For details on any other type of filter, see the [Filter events](#filter-events) section below
55
+
- For details on any other type of filter, see the following [Filter events](#filter-events) section
56
56
57
57
If there's no route name, no messages are routed outside of Azure Digital Twins.
58
58
If there's a route name and the filter is `true`, all messages are routed to the endpoint.
59
-
If there's a route name and a different filter is added, messages will be filtered based on the filter.
59
+
If there's a route name and a different filter is added, messages are filtered based on the filter.
60
60
61
-
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.
61
+
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.
62
62
63
63
# [Portal](#tab/portal2)
64
64
65
-
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).
65
+
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.
66
66
67
67
From the instance menu, select **Event routes**. Then from the **Event routes** page that follows, select **+ Create an event route**.
68
68
69
69
On the **Create an event route** page that opens up, choose at minimum:
70
70
* A name for your route in the **Name** field
71
71
* The **Endpoint** you want to use to create the route
72
72
73
-
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.
73
+
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.
74
74
75
75
:::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":::
76
76
@@ -97,25 +97,25 @@ This section shows how to create an event route using the [.NET (C#) SDK](/dotne
97
97
98
98
### Event route sample SDK code
99
99
100
-
The following sample method shows how to create, list, and delete an event route with the C# SDK:
100
+
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.
108
+
As described previously, routes have a filter field. If the filter value on your route is `false`, no events are sent to your endpoint.
109
109
110
-
After you've enabled a minimal filter of `true`, endpoints will receive different kinds of events from Azure Digital Twins:
110
+
After you enabled a minimal filter of `true`, endpoints will receive different kinds of events from Azure Digital Twins:
111
111
*[Telemetry fired by digital twins](concepts-event-notifications.md#digital-twin-telemetry-messages) using the Azure Digital Twins service API
112
112
* Twin property change notifications, fired on property changes for any twin in the Azure Digital Twins instance
113
113
* Life-cycle events, fired when twins or relationships are created or deleted
114
114
115
115
You can restrict the types of events being sent by defining a more-specific filter.
116
116
117
117
>[!NOTE]
118
-
> 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.
118
+
> 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.
119
119
120
120
# [Portal](#tab/portal3)
121
121
@@ -129,7 +129,7 @@ To use the basic filters, expand the **Event types** option and select the check
129
129
130
130
:::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":::
131
131
132
-
Doing so will autopopulate the filter text box with the text of the filter you've selected:
132
+
Doing so autopopulates the filter text box with the text of the filter you selected:
133
133
134
134
:::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":::
135
135
@@ -158,16 +158,16 @@ Here are the supported route filters.
158
158
| 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 |
159
159
| 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`|
160
160
| 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>`|
161
-
| 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. |
161
+
| 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. |
162
162
| 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`|
163
163
| Content type | Content type of data value |`datacontenttype = '<content-type>'`| The content type is `application/json`|
164
164
| 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 |
165
165
| 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`|
166
166
167
167
>[!NOTE]
168
-
> 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).
168
+
> 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).
169
169
170
-
The following data types are supported as values returned by references to the data above:
170
+
The following data types are supported as values returned by references to the previous data:
171
171
172
172
| Data type | Example |
173
173
|-|-|-|
@@ -192,13 +192,13 @@ The following functions are supported when defining route filters:
192
192
|ENDS_WITH(x,y) | Returns true if the value `x` ends with the string `y`.|`ENDS_WITH($body.$metadata.$model, 'floor;1')`|
193
193
|CONTAINS(x,y)| Returns true if the value `x` contains the string `y`.|`CONTAINS(subject, '<twin-ID>')`|
194
194
195
-
When you implement or update a filter, the change may take a few minutes to be reflected in the data pipeline.
195
+
When you implement or update a filter, the change might take a few minutes to be reflected in the data pipeline.
196
196
197
197
## Monitor event routes
198
198
199
199
Routing metrics such as count, latency, and failure rate can be viewed in the [Azure portal](https://portal.azure.com/).
200
200
201
-
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).
201
+
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