Skip to content

Commit e51166c

Browse files
authored
Merge pull request #296297 from DENKEN02MSFT/ADTFreshnessTop40_Row24_2
ADT Freshness - row 24
2 parents bf586cf + 15f8c0b commit e51166c

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

articles/digital-twins/how-to-ingest-iot-hub-data.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ titleSuffix: Azure Digital Twins
44
description: Learn how to ingest device telemetry messages from Azure IoT Hub to digital twins in an instance of Azure Digital Twins.
55
author: baanders
66
ms.author: baanders # Microsoft employees only
7-
ms.date: 1/3/2024
7+
ms.date: 03/13/2025
88
ms.topic: how-to
99
ms.service: azure-digital-twins
1010
ms.custom: devx-track-azurecli
@@ -26,9 +26,9 @@ This how-to document walks through the process for writing a function that can i
2626

2727
## Prerequisites
2828

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:
3030
* 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).
3232

3333
## Example telemetry scenario
3434

@@ -37,21 +37,21 @@ This how-to outlines how to send messages from IoT Hub to Azure Digital Twins, u
3737
* A digital twin to represent the device, with a matching ID
3838

3939
> [!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).
4141
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:
4343

4444
:::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.":::
4545

4646
## Add a model and twin
4747

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.
4949

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.
5151

5252
[!INCLUDE [digital-twins-thermostat-model-upload.md](../../includes/digital-twins-thermostat-model-upload.md)]
5353

54-
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).
5555

5656
```azurecli-interactive
5757
az dt twin create --dt-name <instance-hostname-or-name> --dtmi "dtmi:contosocom:DigitalTwins:Thermostat;1" --twin-id thermostat67 --properties '{"Temperature": 0.0}'
@@ -74,7 +74,7 @@ When the twin is created successfully, the CLI output from the command should lo
7474

7575
## Create the Azure function
7676

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.
7878

7979
1. First, create a new Azure Functions project of Event Grid trigger type.
8080

@@ -95,29 +95,29 @@ In this section, you'll create an Azure function to access Azure Digital Twins a
9595

9696
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).
9797

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.
9999

100100
```azurecli-interactive
101101
az functionapp function show --resource-group <your-resource-group> --name <your-function-app> --function-name IoTHubToTwins
102102
```
103103

104104
### Configure the function app
105105

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.
107107

108108
[!INCLUDE [digital-twins-configure-function-app-cli.md](../../includes/digital-twins-configure-function-app-cli.md)]
109109

110110
## Connect the function to IoT Hub
111111

112-
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.
113113

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.
115115

116116
```azurecli-interactive
117117
az eventgrid event-subscription create --name <name-for-hub-event-subscription> --event-delivery-schema eventgridschema --source-resource-id /subscriptions/<your-subscription-ID>/resourceGroups/<your-resource-group>/providers/Microsoft.Devices/IotHubs/<your-IoT-hub> --included-event-types Microsoft.Devices.DeviceTelemetry --endpoint-type azurefunction --endpoint /subscriptions/<your-subscription-ID>/resourceGroups/<your-resource-group>/providers/Microsoft.Web/sites/<your-function-app>/functions/IoTHubtoTwins
118118
```
119119

120-
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:
121121

122122
```azurecli
123123
"provisioningState": "Succeeded",
@@ -127,9 +127,9 @@ The output will show information about the event subscription that has been crea
127127

128128
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:
129129

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**.
131131

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.
133133
1. [Register the simulated device with IoT Hub](tutorial-end-to-end.md#register-the-simulated-device-with-iot-hub)
134134
2. [Configure and run the simulation](tutorial-end-to-end.md#configure-and-run-the-simulation)
135135

@@ -139,14 +139,14 @@ After completing these steps, you should have a project console window running a
139139

140140
### Validate results
141141

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).
143143

144144
```azurecli-interactive
145145
az dt twin query --query-command "SELECT * FROM digitaltwins WHERE \$dtId = 'thermostat67'" --dt-name <instance-hostname-or-name>
146146
```
147147

148148
>[!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).
150150
151151
Your output should show the details of the thermostat67 twin, including a temperature value, like this:
152152

@@ -168,7 +168,7 @@ Your output should show the details of the thermostat67 twin, including a temper
168168
}
169169
```
170170

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.
172172

173173
## Next steps
174174

includes/digital-twins-configure-function-app-cli.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ author: baanders
33
description: include file describing how to configure an Azure function to work with Azure Digital Twins - CLI instructions
44
ms.service: azure-digital-twins
55
ms.topic: include
6-
ms.date: 6/16/2022
6+
ms.date: 03/13/2025
77
ms.author: baanders
88
---
99

@@ -13,9 +13,9 @@ Run the following commands in [Azure Cloud Shell](https://shell.azure.com) or a
1313

1414
#### Assign an access role
1515

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.
1717

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.
1919

2020
```azurecli-interactive
2121
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
3434
> [!TIP]
3535
> 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>`.
3636
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.
3838
3939
```azurecli-interactive
4040
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>"

includes/digital-twins-permissions-required.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ author: baanders
33
description: include file describing elevated permissions needed for some management steps
44
ms.service: azure-digital-twins
55
ms.topic: include
6-
ms.date: 2/23/2021
6+
ms.date: 03/13/2025
77
ms.author: baanders
88
---
99

1010
>[!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).

includes/digital-twins-thermostat-model-upload.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ author: baanders
33
description: include file to upload a model to Azure Digital Twins instance
44
ms.service: azure-digital-twins
55
ms.topic: include
6-
ms.date: 4/1/2021
6+
ms.date: 03/13/2025
77
ms.author: baanders
88
---
99

1010
The model looks like this:
1111
:::code language="json" source="~/digital-twins-docs-samples/models/Thermostat.json":::
1212

13-
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).
1414

1515
```azurecli-interactive
1616
az dt model create --dt-name <instance-hostname-or-name> --models '{ "@id": "dtmi:contosocom:DigitalTwins:Thermostat;1", "@type": "Interface", "@context": "dtmi:dtdl:context;2", "contents": [ { "@type": "Property", "name": "Temperature", "schema": "double" } ]}'
1717
```
1818

1919
>[!NOTE]
20-
>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

Comments
 (0)