cschuerc
cschuerc

Reputation: 3

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).

Upvotes: 0

Views: 272

Answers (2)

As explained above, the desire properties are part of your device or module Digital Twin. The Digital Twin is stored in the IoT Hub (in the device registry) and is used to keep the state of your devices in sync with the [cloud] backend services.

The advantage of using the device twin to store your device state is that it can be changed from the backend side, by modifying the device desired properties, and your device will receive the desired property change and then, your device can use the device reported properties to inform that the request change has been accepted (and executed whatever the action it should run in the device). This allows to maintain the device and backend in sync.

For detailed information on device twin and desired and reported properties, check: https://learn.microsoft.com/azure/iot-hub/iot-hub-devguide-device-twins

Upvotes: 0

humblejay
humblejay

Reputation: 347

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.

Upvotes: 1

Related Questions