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-ingest-iot-hub-data.md
+19-19Lines changed: 19 additions & 19 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 ingest device telemetry messages from Azure IoT Hub to digital twins in an instance of Azure Digital Twins.
5
5
author: baanders
6
6
ms.author: baanders # Microsoft employees only
7
-
ms.date: 1/3/2024
7
+
ms.date: 03/13/2025
8
8
ms.topic: how-to
9
9
ms.service: azure-digital-twins
10
10
ms.custom: devx-track-azurecli
@@ -26,9 +26,9 @@ This how-to document walks through the process for writing a function that can i
26
26
27
27
## Prerequisites
28
28
29
-
Before continuing with this example, you'll need to set up the following resources as prerequisites:
29
+
Before continuing with this example, you need to set up the following resources as prerequisites:
30
30
* An IoT hub. For instructions, see the [Create an IoT Hub section of this IoT Hub quickstart](../iot-hub/quickstart-send-telemetry-cli.md).
31
-
* An Azure Digital Twins instance that will receive your device telemetry. For instructions, see [Set up an Azure Digital Twins instance and authentication](./how-to-set-up-instance-portal.md).
31
+
* An Azure Digital Twins instance that receives your device telemetry. For instructions, see [Set up an Azure Digital Twins instance and authentication](./how-to-set-up-instance-portal.md).
32
32
33
33
## Example telemetry scenario
34
34
@@ -37,21 +37,21 @@ This how-to outlines how to send messages from IoT Hub to Azure Digital Twins, u
37
37
* A digital twin to represent the device, with a matching ID
38
38
39
39
> [!NOTE]
40
-
> This example uses a straightforward ID match between the device ID and a corresponding digital twin's ID, but it is possible to provide more sophisticated mappings from the device to its twin (such as with a mapping table).
40
+
> This example uses a straightforward ID match between the device ID and a corresponding digital twin's ID, but it's possible to provide more sophisticated mappings from the device to its twin (such as with a mapping table).
41
41
42
-
Whenever a temperature telemetry event is sent by the thermostat device, a function processes the telemetry and the `Temperature` property of the digital twin should update. This scenario is outlined in a diagram below:
42
+
Whenever the thermostat device sends a temperature telemetry event, a function processes the telemetry and the `Temperature` property of the digital twin should update. This scenario is outlined in the following diagram:
43
43
44
44
:::image type="content" source="media/how-to-ingest-iot-hub-data/events.png" alt-text="Diagram of IoT Hub device sending Temperature telemetry to a function in Azure, which updates a Temperature property on a twin in Azure Digital Twins.":::
45
45
46
46
## Add a model and twin
47
47
48
-
In this section, you'll set up a [digital twin](concepts-twins-graph.md) in Azure Digital Twins that will represent the thermostat device and will be updated with information from IoT Hub.
48
+
In this section, you set up a [digital twin](concepts-twins-graph.md) in Azure Digital Twins that represents the thermostat device and is updated with information from IoT Hub.
49
49
50
-
To create a thermostat-type twin, you'll first need to upload the thermostat [model](concepts-models.md) to your instance, which describes the properties of a thermostat and will be used later to create the twin.
50
+
To create a thermostat-type twin, you first need to upload the thermostat [model](concepts-models.md) to your instance, which describes the properties of a thermostat and is used later to create the twin.
You'll then need to create one twin using this model. Use the following command to create a thermostat twin named thermostat67, and set 0.0 as an initial temperature value. There's one placeholder for the instance's host name (you can also use the instance's friendly name with a slight decrease in performance).
54
+
You then need to create one twin using this model. Use the following command to create a thermostat twin named thermostat67, and set 0.0 as an initial temperature value. There's one placeholder for the instance's host name (you can also use the instance's friendly name with a slight decrease in performance).
@@ -74,7 +74,7 @@ When the twin is created successfully, the CLI output from the command should lo
74
74
75
75
## Create the Azure function
76
76
77
-
In this section, you'll create an Azure function to access Azure Digital Twins and update twins based on IoT device telemetry events that it receives. Follow the steps below to create and publish the function.
77
+
In this section, you create an Azure function to access Azure Digital Twins and update twins based on IoT device telemetry events that it receives. Perform the following steps to create and publish the function.
78
78
79
79
1. First, create a new Azure Functions project of Event Grid trigger type.
80
80
@@ -95,29 +95,29 @@ In this section, you'll create an Azure function to access Azure Digital Twins a
95
95
96
96
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).
97
97
98
-
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, and the name of your function app. The command will print information about the *IoTHubToTwins* function.
98
+
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, and the name of your function app. The command prints information about the *IoTHubToTwins* function.
99
99
100
100
```azurecli-interactive
101
101
az functionapp function show --resource-group <your-resource-group> --name <your-function-app> --function-name IoTHubToTwins
102
102
```
103
103
104
104
### Configure the function app
105
105
106
-
To access Azure Digital Twins, your function app needs a [system-assigned managed identity](../active-directory/managed-identities-azure-resources/overview.md#managed-identity-types) with permissions to access your Azure Digital Twins instance. You'll set that up in this section, by assigning an access role for the function and configuring the application settings so that it can access your Azure Digital Twins instance.
106
+
To access Azure Digital Twins, your function app needs a [system-assigned managed identity](../active-directory/managed-identities-azure-resources/overview.md#managed-identity-types) with permissions to access your Azure Digital Twins instance. You set that up in this section, by assigning an access role for the function and configuring the application settings so that it can access your Azure Digital Twins instance.
In this section, you'll set up your function as an event destination for the IoT hub device data. Setting up your function in this way will ensure that the data from the thermostat device in IoT Hub will be sent to the Azure function for processing.
112
+
In this section, you set up your function as an event destination for the IoT hub device data. Setting up your function in this manner might ensure that the data from the thermostat device in IoT Hub is sent to the Azure function for processing.
113
113
114
-
Use the following CLI command to create an event subscription that the IoT Hub will use to send event data to the *IoTHubtoTwins* function. There's a placeholder for you to enter a name for the event subscription, and there are also placeholders for you to enter your subscription ID, resource group, IoT hub name, and the name of your function app.
114
+
Use the following CLI command to create an event subscription that the IoT Hub uses to send event data to the *IoTHubtoTwins* function. There's a placeholder for you to enter a name for the event subscription, and there are also placeholders for you to enter your subscription ID, resource group, IoT hub name, and the name of your function app.
The output will show information about the event subscription that has been created. You can confirm that the operation completed successfully by verifying the `provisioningState` value in the result:
120
+
The output shows information about the newly created event subscription. You can confirm that the operation completed successfully by verifying the `provisioningState` value in the result:
121
121
122
122
```azurecli
123
123
"provisioningState": "Succeeded",
@@ -127,9 +127,9 @@ The output will show information about the event subscription that has been crea
127
127
128
128
You can test your new ingress function by using the device simulator from [Connect an end-to-end solution](tutorial-end-to-end.md). The *DeviceSimulator* project contains a simulated thermostat device that sends sample temperature data. To set up the device simulator, follow these steps:
129
129
130
-
1. Navigate to the [Azure Digital Twins end-to-end sample project repository](/samples/azure-samples/digital-twins-samples/digital-twins-samples). Get the sample project on your machine by selecting the **Browse code** button underneath the title. This will take you to the GitHub repo for the samples, which you can download as a .zip by selecting the **Code** button followed by **Download ZIP**.
130
+
1. Navigate to the [Azure Digital Twins end-to-end sample project repository](/samples/azure-samples/digital-twins-samples/digital-twins-samples). Get the sample project on your machine by selecting the **Browse code** button underneath the title. This button takes you to the GitHub repo for the samples, which you can download as a .zip by selecting the **Code** button followed by **Download ZIP**.
131
131
132
-
This will download a .zip folder to your machine as *digital-twins-samples-main.zip*. Unzip the folder and extract the files. You'll be using the *DeviceSimulator* project folder.
132
+
This selection downloads a .zip folder to your machine as *digital-twins-samples-main.zip*. Unzip the folder and extract the files. After the files are extracted, you use the *DeviceSimulator* project folder.
133
133
1.[Register the simulated device with IoT Hub](tutorial-end-to-end.md#register-the-simulated-device-with-iot-hub)
134
134
2.[Configure and run the simulation](tutorial-end-to-end.md#configure-and-run-the-simulation)
135
135
@@ -139,14 +139,14 @@ After completing these steps, you should have a project console window running a
139
139
140
140
### Validate results
141
141
142
-
While running the device simulator above, the temperature value of your thermostat digital twin will be changing. In the Azure CLI, run the following command to see the temperature value. There's one placeholder for the instance's host name (you can also use the instance's friendly name with a slight decrease in performance).
142
+
While running the device simulator in a console window as previously shown, the temperature value of your thermostat digital twin changes. In the Azure CLI, run the following command to see the temperature value. There's one placeholder for the instance's host name (you can also use the instance's friendly name with a slight decrease in performance).
143
143
144
144
```azurecli-interactive
145
145
az dt twin query --query-command "SELECT * FROM digitaltwins WHERE \$dtId = 'thermostat67'" --dt-name <instance-hostname-or-name>
146
146
```
147
147
148
148
>[!NOTE]
149
-
>If you're using anything other than Cloud Shell in the Bash environment, you may need to escape the `$` character in the query differently so that it's parsed correctly. For more information, see [Use special characters in different shells](concepts-cli.md#use-special-characters-in-different-shells).
149
+
>If you're using anything other than Cloud Shell in the Bash environment, you might need to escape the `$` character in the query differently so that it parses correctly. For more information, see [Use special characters in different shells](concepts-cli.md#use-special-characters-in-different-shells).
150
150
151
151
Your output should show the details of the thermostat67 twin, including a temperature value, like this:
152
152
@@ -168,7 +168,7 @@ Your output should show the details of the thermostat67 twin, including a temper
168
168
}
169
169
```
170
170
171
-
To see the `Temperature` value change, repeatedly run the query command above.
171
+
To see the `Temperature` value change, repeatedly run the previous query command.
Copy file name to clipboardExpand all lines: includes/digital-twins-configure-function-app-cli.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ author: baanders
3
3
description: include file describing how to configure an Azure function to work with Azure Digital Twins - CLI instructions
4
4
ms.service: azure-digital-twins
5
5
ms.topic: include
6
-
ms.date: 6/16/2022
6
+
ms.date: 03/13/2025
7
7
ms.author: baanders
8
8
---
9
9
@@ -13,9 +13,9 @@ Run the following commands in [Azure Cloud Shell](https://shell.azure.com) or a
13
13
14
14
#### Assign an access role
15
15
16
-
The Azure function requires a bearer token to be passed to it. To make sure the bearer token is passed, grant the function app the **Azure Digital Twins Data Owner** role for your Azure Digital Twins instance, which will give the function app permission to perform data plane activities on the instance.
16
+
The Azure function requires a bearer token to be passed to it. To make sure the bearer token is passed, grant the function app the **Azure Digital Twins Data Owner** role for your Azure Digital Twins instance, which gives the function app permission to perform data plane activities on the instance.
17
17
18
-
1. Use the following command to create a [system-managed identity](../articles/active-directory/managed-identities-azure-resources/overview.md) for your function (if the function already has one, this command will print its details). Take note of the `principalId` field in the output. You'll use this ID to refer to the function so that you can grant it permissions in the next step.
18
+
1. Use the following command to create a [system-managed identity](../articles/active-directory/managed-identities-azure-resources/overview.md) for your function (if the function already has one, this command prints its details). Take note of the `principalId` field in the output. You'll use this ID to refer to the function so that you can grant it permissions in the next step.
19
19
20
20
```azurecli-interactive
21
21
az functionapp identity assign --resource-group <your-resource-group> --name <your-function-app-name>
@@ -34,7 +34,7 @@ Next, make the URL of your Azure Digital Twins instance accessible to your funct
34
34
> [!TIP]
35
35
> The Azure Digital Twins instance's URL is made by adding *https://* to the beginning of your instance's host name. To see the host name, along with all the properties of your instance, run `az dt show --dt-name <your-Azure-Digital-Twins-instance>`.
36
36
37
-
The following command sets an environment variable for your instance's URL that your function will use whenever it needs to access the instance.
37
+
The following command sets an environment variable for your instance's URL that your function uses whenever it needs to access the instance.
38
38
39
39
```azurecli-interactive
40
40
az functionapp config appsettings set --resource-group <your-resource-group> --name <your-function-app-name> --settings "ADT_SERVICE_URL=https://<your-Azure-Digital-Twins-instance-host-name>"
Copy file name to clipboardExpand all lines: includes/digital-twins-permissions-required.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,9 @@ author: baanders
3
3
description: include file describing elevated permissions needed for some management steps
4
4
ms.service: azure-digital-twins
5
5
ms.topic: include
6
-
ms.date: 2/23/2021
6
+
ms.date: 03/13/2025
7
7
ms.author: baanders
8
8
---
9
9
10
10
>[!NOTE]
11
-
> This section must be completed by an Azure user who has permissions to manage user access to Azure resources, including granting and delegating permissions. Common roles that meet this requirement are **Owner**, **Account admin**, or the combination of **User Access Administrator** and **Contributor**. For more information about permission requirements for Azure Digital Twins roles, see [Set up an instance and authentication](../articles/digital-twins/how-to-set-up-instance-portal.md#prerequisites-permission-requirements).
11
+
> An Azure user who has permissions to manage user access to Azure resources, including granting and delegating permissions, must complete this section. Common roles that meet this requirement are **Owner**, **Account admin**, or the combination of **User Access Administrator** and **Contributor**. For more information about permission requirements for Azure Digital Twins roles, see [Set up an instance and authentication](../articles/digital-twins/how-to-set-up-instance-portal.md#prerequisites-permission-requirements).
To upload this model to your twins instance, run the following Azure CLI command, which uploads the above model as inline JSON. You can run the command in [Azure Cloud Shell](../articles/cloud-shell/overview.md) in your browser (use the Bash environment), or on your machine if you have the [CLI installed locally](/cli/azure/install-azure-cli). There's one placeholder for the instance's host name (you can also use the instance's friendly name with a slight decrease in performance).
13
+
To upload this model to your twins instance, run the following Azure CLI command, which uploads the previous model as inline JSON. You can run the command in [Azure Cloud Shell](../articles/cloud-shell/overview.md) in your browser (use the Bash environment), or on your machine if you have the [CLI installed locally](/cli/azure/install-azure-cli). There's one placeholder for the instance's host name (you can also use the instance's friendly name with a slight decrease in performance).
>If you're using anything other than Cloud Shell in the Bash environment, you may need to escape certain characters in the inline JSON so that it's parsed correctly. For more information, see [Use special characters in different shells](../articles/digital-twins/concepts-cli.md#use-special-characters-in-different-shells).
20
+
>If you're using anything other than Cloud Shell in the Bash environment, you might need to escape certain characters in the inline JSON so that it parses correctly. For more information, see [Use special characters in different shells](../articles/digital-twins/concepts-cli.md#use-special-characters-in-different-shells).
0 commit comments