https://github.com/sandervandevelde/iotedgeenvtestsolution
Demonstration of reading custom environment variables by an Azure ioT Edge module.
https://github.com/sandervandevelde/iotedgeenvtestsolution
azure container-create-options custom-module docker environment-variables iot iot-edge
Last synced: about 2 months ago
JSON representation
Demonstration of reading custom environment variables by an Azure ioT Edge module.
- Host: GitHub
- URL: https://github.com/sandervandevelde/iotedgeenvtestsolution
- Owner: sandervandevelde
- Created: 2022-07-14T10:05:31.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-14T11:08:13.000Z (almost 4 years ago)
- Last Synced: 2025-10-29T18:35:46.390Z (8 months ago)
- Topics: azure, container-create-options, custom-module, docker, environment-variables, iot, iot-edge
- Language: Shell
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IoTEdgeEnvTestSolution
Demonstration of reading custom environment variables by an Azure ioT Edge module.
When the module starts, a number of environment variables are read.
_Note_: This includes the already used Azure IoT Edge module specific variables. Check the example below.
## Docker container
The current docker container is available at 'svelde/envtestmodule:0.0.1-amd64' (Please check Docker Hub for more recent versions).
## Envrionment variables
The current implementation looks for these variables:
- variableString
- variableJSON
if one of these is not available, it will be marked are missing.
### variableString
Just past any string.
### variableJSON
Pass a JSON formatted text with these two variables:
```
{
"someInteger" : 42,
"someString" : "Hello module"
}
```
## Example output
This is tested with these environment variables:

The following output is to be expected:
```
IoT Hub module client initialized.
Start reading environment variables:
GetEnvironmentVariables:
IOTEDGE_GATEWAYHOSTNAME = edge-device-test-weu-vm
IOTEDGE_DEVICEID = MessageTest1-1
IOTEDGE_WORKLOADURI = unix:///var/run/iotedge/workload.sock
DOTNET_RUNNING_IN_CONTAINER = true
IOTEDGE_MODULEGENERATIONID = 637933928617587066
IOTEDGE_AUTHSCHEME = sasToken
ASPNETCORE_URLS = http://+:80
HOME = /home/moduleuser
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
variableString = HelloVariable
IOTEDGE_IOTHUBHOSTNAME = xyz.azure-devices.net
variableJSON = { "someInteger" : 42, "someString" : "Hello module" }
HOSTNAME = ef033
IOTEDGE_MODULEID = envtest
IOTEDGE_APIVERSION = 2019-01-30
RuntimeLogLevel = Information
Found 'HelloVariable'
Found '{ "someInteger" : 42, "someString" : "Hello module" }', containing '42' and 'Hello module'
End reading environment variables.
```
As you can see, both the Azure IoT Edge module specific variables and our custom environment variables are shown.
## Usage
This is an alternative to sending Desired properties allthough the impact is there.
The environment variable can only be updated using the Deployment manifest. Each time a deployment manifest is sent, all (other) modules will reload their desired properties.