IotEdge Module Environment

This short article provides a list of all environment variables visible inside of container, which hosts your custom iot edge module.
They have been listed by executing command:

printenv

IOTEDGE_DEVICEID=IOTEDGEDEVICEID
HOSTNAME=037da582dc34
IOTEDGE_GATEWAYHOSTNAME=YOURMACHINENNAME
PWD=/app
HOME=/home/moduleuser
IOTEDGE_WORKLOADURI=http://10.0.75.1:15581/
IOTEDGE_MODULEGENERATIONID=636706377995602534
IOTEDGE_AUTHSCHEME=sasToken
RuntimeLogLevel=Information
IOTEDGE_APIVERSION=2018-06-28
DOTNET_RUNNING_IN_CONTAINER=true
TERM=xterm
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
IOTEDGE_MODULEID=YOURMODULEID
IOTEDGE_IOTHUBHOSTNAME=YOURIOTHUBNAME.azure-devices.net

Thise (most of them) variables are used in SDK when materializing the ModuleClient instance, which is responsible to communication with EdgeHub module.

You can find more about this in following surce code file.
Implementation of factory is here.

Every IotEdge module holds a set of environment variables, which can be used to uniquely identify the module. Following variables can be used to form unique gateway identifier:

IOTEDGE_DEVICEID=ai-01
IOTEDGE_MODULEGENERATIONID=636713944167870115
IOTEDGE_MODULEID=sinusgen
IOTEDGE_IOTHUBHOSTNAME=myhub.azure-devices.net

If required, unique gateway identifier can be formed as follows:

Unique Gateway Identifier = IOTEDGE_IOTHUBHOSTNAME/IOTEDGE_DEVICEID/IOTEDGE_MODULEID/IOTEDGE_MODULEGENERATIONID

Following is an example of unique gateway identifier:

myhub.azure-devices.net/ai-01/sinusgen/636713944167870115


comments powered by Disqus