Reading host's environment variable during IoT Hub layered deployment

Ramon Charalambous 25 Reputation points
2023-06-30T06:19:17.94+00:00

Hello,

We want to use a layered deployment for our custom module in IoT Hub through the Azure Portal, to deploy at scale to our Edge devices in the field.

The IoT Edge module we are deploying requires unique, device-specific values to operate; the values are already set on the target edge devices' Linux OS as environment variables.
So far it seems that evaluation of the host's environment variables is not possible at container startup, so there's no way of reading the host's env vars using configuration in the layered deployment (e.g. container options). I have considered using a file to write the values and read them from inside the application at startup, but the goal here is to do this though configuration rather than code.

So the question is whether there's a "best practices" way to dynamically inject device-specific values taken from the edge device's environment variables into the container's respective env vars, at the time IoTHub's automatic/layered deployment hits the edge device/container start-up?

Any samples/docs on this would be greatly appreciated.

Thanks.

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.
598 questions
{count} vote

Accepted answer
  1. LeelaRajeshSayana-MSFT 17,766 Reputation points Moderator
    2023-06-30T20:23:29.1+00:00

    Hi @Ramon Charalambous Greetings! I have checked with the product team on this request.

    Your observations on this are correct. This feature is not supported with the current implementation of IoT Edge. The product team did not have any recommendations or better approaches on this use case. The route you are following to utilize a file to write the values and read them from inside the application at startup seems to be the way to go for now.

    I have come across a similar feature request idea posted on the Azure IoT Edge ideas page. Here is the link for the request Allow for placeholder variables in IoT Edge deployment templates I have upvoted the idea. I request you to do the same so the product team can look into it and prioritize accordingly.

    I understand that this situation may have caused some inconvenience, and I want to express my gratitude for your efforts and patience in handling it. 


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.