0

I have an application running on an Azure IoT Edge Runtime which needs to keep values of properties which are changed at runtime by the user. So basically after restarting the device, the user changed data shall still remain. So far I can just store the data to any local storage - no problem.

But when me Edge Device (the hardware) is changed, I would like to but a new one in place and no data shall be lost.

Maybe I'm able to change the device twin desired properties from my edge device application?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Regarding your question about changing the device twin's desired properties from your edge device application, you can use the Azure IoT SDKs to update the device twin properties programmatically. You can also use Azure IoT Central to manage devices individually and modify their properties. – Sampath May 16 '23 at 12:46
  • which run time SDK are you using – Sampath May 16 '23 at 12:47
  • IoT central properties reference [doc](https://learn.microsoft.com/en-us/azure/iot-central/core/concepts-telemetry-properties-commands) – Sampath May 16 '23 at 23:20

1 Answers1

0

Yes, using the device twin desired properties to store runtime data in the cloud and persist it across device restarts and replacements.

The device twin is a JSON document, stores metadata and configuration information.

enter image description here

To update the desired properties from Edge device application, use the Azure IoT SDKs to send a device twin update message to the cloud. The message should contain the updated desired properties for the device twin.

When replacing the Edge device, you can create a new device twin with the same desired properties as the old device twin, and the runtime data will be restored. And also update the desired properties of the device twin from Edge device application to persist changes done.

To copy the device twin from the old device

-Use the Azure IoT Hub REST API or the Azure IoT SDK.

Mydevice_client = IoTHubDeviceClient.create_from_connection_string(connectionSTring);
desired_properties = {
    "property1": "value1",
    "property2": "value2"
}
  • The Edge device application has the necessary permissions to read and write to the device twin. And configure the permissions using Azure IoT Hub access policies.

For more information refer to the MSDoc.

Rajesh Mopati
  • 1,329
  • 1
  • 2
  • 7