azure-iot-edge

Azure IoT edge devices: Differences between desired properties and environment variables


I have an Azure IoT edge device. This edge device has one module that simulates a real machine. I would like to configure this edge module (e.g. the simulation time interval, number of items to simulate). I could use either desired properties or environment variables for that. Which makes more sense? What are the intentions and the main differences between desired properties and environment variables?

I don't see much differences as:

The only difference I see so far is that I can subscribe to changes to desired properties. This doesn't seem to be possible for changes to environment variables (however, then the module would restart and read the new environment variables).


Solution

  • Desired properties represent the state of your module and is better suited than environment variables for few reasons.

    1. Change in desired properties triggers method on the device without restart of the module, which in case of environment variable is necessary
    2. At scale, changing desired properties is possible via Jobs API, while for environment variables, you will need to build additional automation
    3. Desired properties are part of the device twin, which is kept in sync on the cloud side, while environment variables are part of deployment manifest. Twin is better suited to represent the device state than the environment variable.