Each Azure IoT Edge module, deployed to a device, has its own Module twin.
A Module twin is the same concept as a Device twin for an Azure IoT Device, it stores state information including metadata, configurations, and conditions.
A Module twin is essentially a JSON document which lives both in the cloud (in the IoT Hub) and on the device and is kept in sync when communication between device and cloud is possible:

In the IoT Hub, the tags are writable and readable. These can be used to identify a specific device with an alternative key and/or to filter subsets of devices.
Also in the cloud, the desired properties can be written with updated values. These (updated) values (eg. properties or settings) are picked up by the device when it is connected. So it could take days or weeks for the updated desired property to be picked up because the device is offline in the meanwhile.
But the desired properties are patient…
Once the updated values of changed desired properties are arriving at a device, a notification method on the device is triggered to handle them.
As a good citizen, an IoT Edge module should report back to the cloud how it is updated by the desired properties. This is done using the reported properties in the Module twin.
This closes the loop for the administrator. I can publish a desired property change for one or more devices. And after a while, the reported properties can be checked to see which devices have picked them up and which devices need some attention.
Do you notice that it’s also possible to read reported properties, on the module side?
Write data, read data… that is enough to persist data on the edge, isn’t it?
Let’s see how we can use this for persisting local state.
Doorgaan met het lezen van “Adding local persisted state to IoT Edge modules using Module twin”