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-send-twin-to-twin-events.md
+11-11Lines changed: 11 additions & 11 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 create a function in Azure for propagating events through the twin graph.
5
5
author: baanders
6
6
ms.author: baanders # Microsoft employees only
7
-
ms.date: 02/28/2025
7
+
ms.date: 03/10/2025
8
8
ms.topic: how-to
9
9
ms.service: azure-digital-twins
10
10
ms.custom: devx-track-azurecli
@@ -17,25 +17,25 @@ ms.devlang: azurecli
17
17
18
18
# Set up twin-to-twin event handling
19
19
20
-
This article shows how to send events from twin to twin, so that when one digital twin in the graph is updated, related twins in the graph that are affected by this information can also update. This event handling will help you create a fully connected Azure Digital Twins graph, where data that arrives into Azure Digital Twins from external sources like IoT Hub is propagated through the entire graph.
20
+
This article shows how to send events from twin to twin, so that when one digital twin in the graph is updated, related twins in the graph affected by this information can also update. This event handling helps you create a fully connected Azure Digital Twins graph, where data that arrives into Azure Digital Twins from external sources like IoT Hub is propagated through the entire graph.
21
21
22
-
To set up this twin-to-twin event handling, you'll create an [Azure function](../azure-functions/functions-overview.md) that watches for twin life-cycle events. The function recognizes which events should affect other twins in the graph, and uses the event data to update the affected twins accordingly.
22
+
To set up this twin-to-twin event handling, you create an [Azure function](../azure-functions/functions-overview.md) that watches for twin life-cycle events. The function recognizes which events should affect other twins in the graph, and uses the event data to update the affected twins accordingly.
23
23
24
24
## Prerequisites
25
25
26
-
To set up twin-to-twin handling, you'll need an Azure Digital Twins instance to work with. For instructions on how to create an instance, see [Set up an Azure Digital Twins instance and authentication](./how-to-set-up-instance-portal.md). The instance should contain at least two twins that you want to send data between.
26
+
To set up twin-to-twin handling, you need an Azure Digital Twins instance to work with. For instructions on how to create an instance, see [Set up an Azure Digital Twins instance and authentication](./how-to-set-up-instance-portal.md). The instance should contain at least two twins that you want to send data between.
27
27
28
-
Optionally, you may want to set up [automatic telemetry ingestion through IoT Hub](how-to-ingest-iot-hub-data.md) for your twins as well. This process isn't required to send data from twin to twin, but it's an important piece of a complete solution where the twin graph is driven by live device telemetry.
28
+
Optionally, you might want to set up [automatic telemetry ingestion through IoT Hub](how-to-ingest-iot-hub-data.md) for your twins as well. This process isn't required to send data from twin to twin, but it's an important piece of a complete solution where live device telemetry drives the twin graph.
29
29
30
30
## Send twin events to an endpoint
31
31
32
-
To set up twin-to-twin event handling, start by creating an *endpoint* in Azure Digital Twins and a *route* to that endpoint. Twins undergoing an update will use the route to send information about their update events to the endpoint (where Event Grid can pick them up later and pass them to an Azure function for processing).
32
+
To set up twin-to-twin event handling, start by creating an *endpoint* in Azure Digital Twins and a *route* to that endpoint. Twins undergoing an update use the route to send information about their update events to the endpoint (where Event Grid can pick them up later and pass them to an Azure function for processing).
Next, create an Azure function that will listen on the endpoint and receive twin events that are sent there via the route. The logic of the function should use the information in the events to determine what other twins need to be updated and then perform the updates.
38
+
Next, create an Azure function that listens on the endpoint and receive twin events that are sent there via the route. The logic of the function should use the information in the events to determine what other twins need to be updated and then perform the updates.
39
39
40
40
1. First, create a new Azure Functions project.
41
41
@@ -53,23 +53,23 @@ Next, create an Azure function that will listen on the endpoint and receive twin
53
53
54
54
For instructions on how to publish the function using **Visual Studio**, see [Develop Azure Functions using Visual Studio](../azure-functions/functions-develop-vs.md#publish-to-azure). For instructions on how to publish the function using **Visual Studio Code**, see [Create a C# function in Azure using Visual Studio Code](../azure-functions/create-first-function-vs-code-csharp.md?tabs=in-process#publish-the-project-to-azure). For instructions on how to publish the function using the **Azure CLI**, see [Create a C# function in Azure from the command line](../azure-functions/create-first-function-cli-csharp.md?tabs=azure-cli%2Cin-process#deploy-the-function-project-to-azure).
55
55
56
-
Once the process of publishing the function completes, you can use this Azure CLI command to verify the publish was successful. There are placeholders for your resource group, the name of your function app, and the name of your specific function. The command will print information about your function.
56
+
Once the process of publishing the function completes, you can use this Azure CLI command to verify the publish was successful. There are placeholders for your resource group, the name of your function app, and the name of your specific function. The command prints information about your function.
57
57
58
58
```azurecli-interactive
59
59
az functionapp function show --resource-group <your-resource-group> --name <your-function-app> --function-name <your-function>
60
60
```
61
61
62
62
### Configure the function app
63
63
64
-
Before your function can access Azure Digital Twins, it needs some information about the instance and permission to access it. In this section, you'll assign an access role for the function and configure the application settings so that it can find and access the instance.
64
+
Before your function can access Azure Digital Twins, it needs some information about the instance and permission to access it. In this section, you assign an access role for the function and configure the application settings so that it can find and access the instance.
Next, subscribe your Azure function to the Event Grid endpoint you created earlier. Doing so will ensure that data can flow from an updated twin through the Event Grid topic to the function, which can use the event information to update other twins as needed.
70
+
Next, subscribe your Azure function to the Event Grid endpoint you created earlier. Doing so ensures that data can flow from an updated twin through the Event Grid topic to the function, which can use the event information to update other twins as needed.
71
71
72
-
To subscribe your Azure function, you'll create an *Event Grid subscription* that sends data from the Event Grid topic that you created earlier to your Azure function.
72
+
To subscribe your Azure function, you create an *Event Grid subscription* that sends data from the Event Grid topic that you created earlier to your Azure function.
73
73
74
74
Use the following CLI command, filling in placeholders for your subscription ID, resource group, function app, and function name.
0 commit comments