Is it possible to edit the Device Twin to make IoT Edge Device in Offline Mode while we deploy it in virtual machine

Dhanavath Vishnu 366 Reputation points
2023-05-31T17:39:28.67+00:00

Hi Team

Hello @satishbodduakon ,

I am thinking of testing IoT Edge device in offline mode, to create the offline mode scenario, is there any parameter we can change/monitor from the device twin of IoT Edge device.

Is it possible to force the device/virtual machine to go offline, once the IoT Edge deployment is done and synced with the IoT HUB.

Let me know your inputs on it.

One more question I am having, is there anyway the IoTEdge modules/device can read the iothubowner policy primary connection string as environment variable. We are working one of the scenarios of reliability communication test between the different modules in the IoT Edge environment.

Thanks

D. Vishnu

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
558 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,153 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,956 Reputation points
    2023-06-20T21:44:28.4+00:00

    Hi @Dhanavath Vishnu Apologies for the delayed feedback on this. I have checked with the product team on the possibility this use case. I have been informed that with the current implementation, we do not have a possibility to configure the device offline mode configurations using a Device Twin.

    is there anyway the IoTEdge modules/device can read the iothubowner policy primary connection string as environment variable

    As far as I can tell, the IoTHub owner policy connection string is not accessible to the IoT Edge module by default. You can use the Azure CLI command az iot hub show-connection-string --policy-name iothubowner --name <hub-name> --output tsv or access Shared Access policy section of IoT Hub on Azure portal to get the IoT Hub owner connection string. You can then update the module twin with the Environment variable by adding the following in the deployment-manifest.json file under the module section.

                "env": {
                  "IoTHubConnectionString": {"value": "<ConnectionString>"}
                }
    
    
    

    Once the twin gets updates, it will store the connection string value in the module's environment variable. Please note that the connection string set using this approach would be displayed in plain text.

    Hope this helps. Please let us know if you have any additional questions or need further assistance on this.

    0 comments No comments