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
* The structure of the device twin: *tags*, *desired properties*, and *reported properties*.
23
-
* The operations that device and back-end applications can perform on device twins.
23
+
* The operations that [*device applications*](../iot/iot-glossary.md#device-app)and the [*solution back end*](../iot/iot-glossary.md#solution-back-end) can perform on device twins.
24
24
25
25
Use device twins to:
26
26
27
27
* Store device-specific metadata in the cloud. For example, the location of a vending machine.
28
28
29
29
* Report current state information such as available capabilities and conditions from your device app. For example, whether a device is connected to your IoT hub over cellular or WiFi.
30
30
31
-
* Synchronize the state of long-running workflows between device app and back-end app. For example, when the solution backend specifies the new firmware version to install, and the device app reports the various stages of the update process.
31
+
* Synchronize the state of long-running workflows between device app and back-end apps. For example, when a back-end app specifies the new firmware version to install, and the device app reports the various stages of the update process.
32
32
33
33
* Query your device metadata, configuration, or state.
34
34
@@ -42,21 +42,21 @@ To learn how device twins relate to the device model used by an Azure IoT Plug a
42
42
43
43
Device twins store device-related information that:
44
44
45
-
* Device and back ends can use to synchronize device conditions and configuration.
45
+
* Device apps and back-end apps can use to synchronize device conditions and configuration.
46
46
47
47
* The solution back end can use to query and target long-running operations.
48
48
49
49
The lifecycle of a device twin is linked to its corresponding [device identity](iot-hub-devguide-identity-registry.md). Device twins are implicitly created and deleted when a device identity is created or deleted in IoT Hub.
50
50
51
51
A device twin is a JSON document that includes:
52
52
53
-
***Tags**. A section of the JSON document that the solution backend can read from and write to. Tags aren't visible to device apps.
53
+
***Tags**. A section of the JSON document that back-end apps can read from and write to. Tags aren't visible to device apps.
54
54
55
-
***Desired properties**. Used along with reported properties to synchronize device configuration or conditions. The solution back end can set desired properties, and the device app can read them. The device app can also receive notifications of changes in the desired properties.
55
+
***Desired properties**. Used along with reported properties to synchronize device configuration or conditions. Back-end apps can set desired properties, and the device app can read them. The device app can also receive notifications of changes in the desired properties.
56
56
57
-
***Reported properties**. Used along with desired properties to synchronize device configuration or conditions. The device app can set reported properties, and the solution backend can read and query them.
57
+
***Reported properties**. Used along with desired properties to synchronize device configuration or conditions. The device app can set reported properties, and back-end apps can read and query them.
58
58
59
-
***Device identity properties**. The root of the device twin JSON document contains the read-only properties from the corresponding device identity stored in the [identity registry](iot-hub-devguide-identity-registry.md). Properties`connectionStateUpdatedTime` and `generationId`won't be included.
59
+
***Device identity properties**. The root of the device twin JSON document contains the read-only properties from the corresponding device identity stored in the [identity registry](iot-hub-devguide-identity-registry.md). The`connectionStateUpdatedTime` and `generationId`properties aren't included.
60
60
61
61

62
62
@@ -109,16 +109,16 @@ The root object contains the device identity properties, and container objects f
109
109
110
110
### Reported property example
111
111
112
-
In the previous example, the device twin contains a `batteryLevel`property that is reported by the device app. This property makes it possible to query and operate on devices based on the last reported battery level. Other examples include the device app reporting device capabilities or connectivity options.
112
+
In the previous example, the device twin contains a `batteryLevel` reported property. This property makes it possible to query and operate on devices based on the last reported battery level. Other examples include the device app reporting device capabilities or connectivity options.
113
113
114
114
> [!NOTE]
115
-
> Reported properties simplify scenarios where the solution back end is interested in the last known value of a property. Use [device-to-cloud messages](iot-hub-devguide-messages-d2c.md) if the solution back end needs to process device telemetry in the form of sequences of timestamped events, such as time series.
115
+
> Reported properties simplify scenarios where you're interested in the last known value of a property. Use [device-to-cloud messages](iot-hub-devguide-messages-d2c.md) if you want to process device telemetry in the form of sequences of timestamped events, such as time series.
116
116
117
117
### Desired property example
118
118
119
119
In the previous example, the `telemetryConfig` device twin desired and reported properties are used by the solution back end and the device app to synchronize the telemetry configuration for this device. For example:
120
120
121
-
1.The solution backend sets the desired property with the desired configuration value. Here's the portion of the document with the desired property set:
121
+
1.A back-end app sets the desired property with the desired configuration value. Here's the portion of the document with the desired property set:
122
122
123
123
```json
124
124
"desired": {
@@ -141,7 +141,7 @@ In the previous example, the `telemetryConfig` device twin desired and reported
141
141
}
142
142
```
143
143
144
-
3.The solution backend tracks the results of the configuration operation across many devices by [querying](iot-hub-devguide-query-language.md) device twins.
144
+
3.A back-end app tracks the results of the configuration operation across many devices by [querying](iot-hub-devguide-query-language.md) device twins.
145
145
146
146
> [!NOTE]
147
147
> The preceding snippets are examples, optimized for readability, of one way to encode a device configuration and its status. IoT Hub does not impose a specific schema for the device twin desired and reported properties in the device twins.
@@ -157,7 +157,7 @@ The solution back end operates on the device twin using the following atomic ope
157
157
158
158
***Retrieve device twin by ID**. This operation returns the device twin document, including tags and desired and reported system properties.
159
159
160
-
***Partially update device twin**. This operation enables the solution back end to partially update the tags or desired properties in a device twin. The partial update is expressed as a JSON document that adds or updates any property. Properties set to `null` are removed. The following example creates a new desired property with value `{"newProperty": "newValue"}`, overwrites the existing value of `existingProperty` with `"otherNewValue"`, and removes `otherOldProperty`. No other changes are made to existing desired properties or tags:
160
+
***Partially update device twin**. This operation partially updates the tags or desired properties in a device twin. The partial update is expressed as a JSON document that adds or updates any property. Properties set to `null` are removed. The following example creates a new desired property with value `{"newProperty": "newValue"}`, overwrites the existing value of `existingProperty` with `"otherNewValue"`, and removes `otherOldProperty`. No other changes are made to existing desired properties or tags:
161
161
162
162
```json
163
163
{
@@ -173,11 +173,11 @@ The solution back end operates on the device twin using the following atomic ope
173
173
}
174
174
```
175
175
176
-
***Replace desired properties**. This operation enables the solution back end to completely overwrite all existing desired properties and substitute a new JSON document for `properties/desired`.
176
+
***Replace desired properties**. This operation completely overwrites all existing desired properties and substitutes a new JSON document for `properties/desired`.
177
177
178
-
***Replace tags**. This operation enables the solution back end to completely overwrite all existing tags and substitute a new JSON document for `tags`.
178
+
***Replace tags**. This operation completely overwrites all existing tags and substitutes a new JSON document for `tags`.
179
179
180
-
***Receive twin notifications**. This operation allows the solution back end to be notified when the twin is modified. To do so, your IoT solution needs to create a route and to set the Data Source equal to *twinChangeEvents*. By default, no such route exists, so no twin notifications are sent. If the rate of change is too high, or for other reasons such as internal failures, the IoT Hub might send only one notification that contains all changes. Therefore, if your application needs reliable auditing and logging of all intermediate states, you should use device-to-cloud messages. To learn more about the properties and body returned in the twin notification message, see [Nontelemetry event schemas](iot-hub-non-telemetry-event-schema.md).
180
+
***Receive twin notifications**. This operation notifies when the twin is modified. To receive device twin change notifications, your IoT solution needs to create a route and to set the Data Source equal to *twinChangeEvents*. By default, no such route exists, so no twin notifications are sent. If the rate of change is too high, or for other reasons such as internal failures, the IoT Hub might send only one notification that contains all changes. Therefore, if your application needs reliable auditing and logging of all intermediate states, you should use device-to-cloud messages. To learn more about the properties and body returned in the twin notification message, see [Nontelemetry event schemas](iot-hub-non-telemetry-event-schema.md).
181
181
182
182
All the preceding operations support [Optimistic concurrency](iot-hub-devguide-device-twins.md#optimistic-concurrency) and require the **ServiceConnect** permission, as defined in [Control access to IoT Hub](iot-hub-dev-guide-sas.md).
183
183
@@ -193,9 +193,9 @@ The device app operates on the device twin using the following atomic operations
193
193
194
194
***Retrieve device twin**. This operation returns the device twin document (including desired and reported system properties) for the currently connected device. (Tags aren't visible to device apps.)
195
195
196
-
***Partially update reported properties**. This operation enables the partial update of the reported properties of the currently connected device. This operation uses the same JSON update format that the solution back end uses for a partial update of desired properties.
196
+
***Partially update reported properties**. This operation enables the partial update of the reported properties of the currently connected device.
197
197
198
-
***Observe desired properties**. The currently connected device can choose to be notified of updates to the desired properties when they happen. The device receives the same form of update (partial or full replacement) executed by the solution back end.
198
+
***Observe desired properties**. The currently connected device can choose to be notified of updates to the desired properties when they happen.
199
199
200
200
All the preceding operations require the **DeviceConnect** permission, as defined in [Control Access to IoT Hub](iot-hub-dev-guide-sas.md).
201
201
@@ -254,7 +254,7 @@ IoT Hub enforces an 8-KB size limit on the value of `tags`, and a 32-KB size lim
254
254
255
255
Twin size is computed as follows:
256
256
257
-
*For each property in the JSON document, IoT Hub cumulatively computes and adds the length of the property's key and value.
257
+
* IoT Hub cumulatively computes and adds the length of each property's key and value.
258
258
259
259
* Property keys are considered as UTF8-encoded strings.
260
260
@@ -327,7 +327,7 @@ Tags, desired properties, and reported properties all support optimistic concurr
327
327
328
328
Device twins have an ETag property `etag`, as per [RFC7232](https://tools.ietf.org/html/rfc7232), that represents the twin's JSON representation. You can use the `etag` property in conditional update operations from the solution back end to ensure consistency. This property is the only option for ensuring consistency in operations that involve the `tags` container.
329
329
330
-
Device twin desired and reported properties also have a `$version` value that is guaranteed to be incremental. Similarly to an ETag, the version can be used by the updating party to enforce consistency of updates. For example, a device app for a reported property or the solution backend for a desired property.
330
+
Device twin desired and reported properties also have a `$version` value that is guaranteed to be incremental. Similarly to an ETag, you can use the version property to enforce consistency of updates. For example, a device app for a reported property or a back-end app for a desired property.
331
331
332
332
Versions are also useful when an observing agent (such as the device app observing the desired properties) must reconcile races between the result of a retrieve operation and an update notification. The [Device reconnection flow section](#device-reconnection-flow) provides more information.
0 commit comments