azureazure-iot-edgeazure-iot-hub-device-management

Azure IOT Hub module / Environmental Variable


Long road of learning, and wading through older documents, I finally deploying my IOT Edge module to IOT Hub using this command:

az iot edge set-modules --hubname xxx --device-Id yy --content ./deployment.arm64vf8.json

When I run this command, i review these screens: enter image description here enter image description here

However, how do I set Environmental Variables from the JSON file? enter image description here


Solution

  • The environment variables are in env section of the deployment JSON.

    Example:

    {
      "modulesContent": {
        "$edgeAgent": {
          "properties.desired.modules.EdgeModule": {
            "version": "1.0.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "mcr.microsoft.com/dotnet/samples:aspnetapp",
              "createOptions": "{\"PortBindings\":{\"80/tcp\":[{\"HostPort\":\"8080\"}]}}}"
            },
            "env": {
              "ASPNETCORE_ENVIRONMENT": {
                "value": "Production"
              }
            }
          }
        }
      }
    }