Azure IoT Serivce has a Device Template and a Device Twin. How are those two connected - I haven't found an article that clarifies that yet. What is the difference, how are they related? I assume the following: the device twin is derived from the properties,... of the device template. Where can I find the raw device twin data in IoT Central?
1 Answers
You're correct that they're related - here's a summary:
- The device template is an IoT Central only concept.
- The device twins concept is applicable to both IoT Hub and IoT Central.
The Device Template defines the capabilities of a device that connects to IoT Central - the capabilities include the telemetry the device sends, the properties that represent the device state, and the commands that the device can respond to. IoT Central uses the device template to define a UI for the device letting you plot telemetry, manage properties, and call commands.
The Device Twin is an abstraction that lets you work with device properties both on the device and in the cloud. Conceptually, a Device Twin is a JSON representation of the device properties (state) that's synced between the device and the cloud. Some properties are read-only which means only the device can modify them. Some properties are read/write which means both the device and the cloud can modify them. A device twin is a useful abastraction for device and cloud developers writing code that interacts with device properties.
The part of the device template that defines the device properties, in effect defines the structure of the device twin that's shared between the device and IoT Central. In IoT Central, you can define views that let you see the device properties, and forms that let you manage read/write device properties. Because IoT Central has GUI tools that you can customize to work with device properties, the device twin concept is less important when you're working with IoT Central.
You can view the raw data that IoT Central receives from a device on the "Raw data" tab for a device:

- 2,306
- 1
- 18
- 10
-
So you mean, when using the SDKs of Azure the device twin schema is used for sync behind the scences? – user3579222 Jul 18 '22 at 14:22
-
1Exactly, the SDKs provide full support for using the device twins. The device SDKs let you manage the device twin on the device and let you sync changes with the service, the service SDKs let you read device twin data in the cloud and update read/write properties. – Dominic Betts Jul 18 '22 at 14:55
-
1> Some properties are read/write which means both the device and the cloud can modify them. That's not precise. *Tags* and *Desired* are writable for Cloud part only, *Reported* are writable for Device side only. – tymtam Jul 19 '22 at 02:19
-
1@tymtam - you're quite correct. We have different terminology when we talk about properties with IoT Hub as opposed to IoT Central. IoT Central simplifies things a bit by having read-only properties which are read only in IoT Central and writable on the device, and writable properties that are writable in IoT Central and on the device. IoT Central follows the [plug and play convention](https://learn.microsoft.com/azure/iot-develop/concepts-convention) - the default behavior for a property defined in a DTDL model is read-only, but properties can be tagged as writable in the model. – Dominic Betts Jul 20 '22 at 07:18
-
@DominicBetts thanks for the update, I'll keep this in mind. – tymtam Jul 20 '22 at 07:38