Skip to content

Commit 2755755

Browse files
authored
Merge pull request #101837 from JimacoMS3/fix-gh-45003-device-twin-object-limitations
clarify tags and reported/desired properties size limits per gh 45003
2 parents 73a6133 + cb75983 commit 2755755

File tree

2 files changed

+41
-17
lines changed

2 files changed

+41
-17
lines changed

articles/iot-hub/iot-hub-devguide-device-twins.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.author: wesmc
77
ms.service: iot-hub
88
services: iot-hub
99
ms.topic: conceptual
10-
ms.date: 06/10/2019
10+
ms.date: 02/01/2020
1111
---
1212

1313
# Understand and use device twins in IoT Hub
@@ -240,11 +240,15 @@ The [Azure IoT device SDKs](iot-hub-devguide-sdks.md) make it easy to use the pr
240240

241241
Tags, desired properties, and reported properties are JSON objects with the following restrictions:
242242

243-
* All keys in JSON objects are UTF-8 encoded, case-sensitive, and up-to 1 KB in length. Allowed characters exclude UNICODE control characters (segments C0 and C1), and `.`, `$`, and SP.
243+
* **Keys**: All keys in JSON objects are UTF-8 encoded, case-sensitive, and up-to 1 KB in length. Allowed characters exclude UNICODE control characters (segments C0 and C1), and `.`, `$`, and SP.
244244

245-
* All values in JSON objects can be of the following JSON types: boolean, number, string, object. Arrays are not allowed. The maximum value for integers is 4503599627370495 and the minimum value for integers is -4503599627370496.
245+
* **Values**: All values in JSON objects can be of the following JSON types: boolean, number, string, object. Arrays are not allowed.
246246

247-
* All JSON objects in tags, desired, and reported properties can have a maximum depth of 10. For instance, the following object is valid:
247+
* Integers can have a minimum value of -4503599627370496 and a maximum value of 4503599627370495.
248+
249+
* String values are UTF-8 encoded and can have a maximum length of 4 KB.
250+
251+
* **Depth**: The maximum depth of JSON objects in tags, desired properties, and reported properties is 10. For example, the following object is valid:
248252

249253
```json
250254
{
@@ -276,15 +280,23 @@ Tags, desired properties, and reported properties are JSON objects with the foll
276280
}
277281
```
278282

279-
* All string values can be at most 4 KB in length.
280-
281283
## Device twin size
282284

283-
IoT Hub enforces an 8 KB size limit on the value of `tags`, and a 32 KB size limit each on the value of `properties/desired` and `properties/reported`. These totals are exclusive of read-only elements.
285+
IoT Hub enforces an 8 KB size limit on the value of `tags`, and a 32 KB size limit each on the value of `properties/desired` and `properties/reported`. These totals are exclusive of read-only elements like `$etag`, `$version`, and `$metadata/$lastUpdated`.
286+
287+
Twin size is computed as follows:
288+
289+
* For each property in the JSON document, IoT Hub cumulatively computes and adds the length of the property's key and value.
290+
291+
* Property keys are considered as UTF8-encoded strings.
292+
293+
* Simple property values are considered as UTF8-encoded strings, numeric values (8 Bytes), or Boolean values (4 Bytes).
294+
295+
* The size of UTF8-encoded strings is computed by counting all characters, excluding UNICODE control characters (segments C0 and C1).
284296

285-
The size is computed by counting all characters, excluding UNICODE control characters (segments C0 and C1) and spaces that are outside of string constants.
297+
* Complex property values (nested objects) are computed based on the aggregate size of the property keys and property values that they contain.
286298

287-
IoT Hub rejects with an error all operations that would increase the size of those documents above the limit.
299+
IoT Hub rejects with an error all operations that would increase the size of the `tags`, `properties/desired`, or `properties/reported` documents above the limit.
288300

289301
## Device twin metadata
290302

articles/iot-hub/iot-hub-devguide-module-twins.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: chrissie926
55
ms.service: iot-hub
66
services: iot-hub
77
ms.topic: conceptual
8-
ms.date: 04/26/2018
8+
ms.date: 02/01/2020
99
ms.author: menchi
1010
---
1111

@@ -231,11 +231,15 @@ The [Azure IoT device SDKs](iot-hub-devguide-sdks.md) make it easy to use the pr
231231

232232
Tags, desired properties, and reported properties are JSON objects with the following restrictions:
233233

234-
* All keys in JSON objects are case-sensitive 64 bytes UTF-8 UNICODE strings. Allowed characters exclude UNICODE control characters (segments C0 and C1), and `.`, SP, and `$`.
234+
* **Keys**: All keys in JSON objects are case-sensitive 64 bytes UTF-8 UNICODE strings. Allowed characters exclude UNICODE control characters (segments C0 and C1), and `.`, SP, and `$`.
235235

236-
* All values in JSON objects can be of the following JSON types: boolean, number, string, object. Arrays are not allowed. The maximum value for integers is 4503599627370495 and the minimum value for integers is -4503599627370496.
236+
* **Values**: All values in JSON objects can be of the following JSON types: boolean, number, string, object. Arrays are not allowed.
237237

238-
* All JSON objects in tags, desired, and reported properties can have a maximum depth of 5. For instance, the following object is valid:
238+
* Integers can have a minimum value of -4503599627370496 and a maximum value of 4503599627370495.
239+
240+
* String values are UTF-8 encoded and can have a maximum length of 512 bytes.
241+
242+
* **Depth**: All JSON objects in tags, desired, and reported properties can have a maximum depth of 5. For instance, the following object is valid:
239243

240244
```json
241245
{
@@ -257,13 +261,21 @@ Tags, desired properties, and reported properties are JSON objects with the foll
257261
}
258262
```
259263

260-
* All string values can be at most 512 bytes in length.
261-
262264
## Module twin size
263265

264-
IoT Hub enforces an 8 KB size limit on the value of `tags`, and a 32 KB size limit each on the value of `properties/desired` and `properties/reported`. These totals are exclusive of read-only elements.
266+
IoT Hub enforces an 8 KB size limit on the value of `tags`, and a 32 KB size limit each on the value of `properties/desired` and `properties/reported`. These totals are exclusive of read-only elements like `$etag`, `$version`, and `$metadata/$lastUpdated`.
267+
268+
Twin size is computed as follows:
269+
270+
* For each property in the JSON document, IoT Hub cumulatively computes and adds the length of the property's key and value.
271+
272+
* Property keys are considered as UTF8-encoded strings.
273+
274+
* Simple property values are considered as UTF8-encoded strings, numeric values (8 Bytes), or Boolean values (4 Bytes).
275+
276+
* The size of UTF8-encoded strings is computed by counting all characters, excluding UNICODE control characters (segments C0 and C1).
265277

266-
The size is computed by counting all characters, excluding UNICODE control characters (segments C0 and C1) and spaces that are outside of string constants.
278+
* Complex property values (nested objects) are computed based on the aggregate size of the property keys and property values that they contain.
267279

268280
IoT Hub rejects with an error all operations that would increase the size of those documents above the limit.
269281

0 commit comments

Comments
 (0)