Coder Social home page Coder Social logo

sandervandevelde / iotedgeenvtestsolution Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 18 KB

Demonstration of reading custom environment variables by an Azure ioT Edge module.

Dockerfile 5.29% Shell 60.13% C# 34.58%
azure iot iot-edge custom-module docker environment-variables container-create-options

iotedgeenvtestsolution's Introduction

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:

image

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.

iotedgeenvtestsolution's People

Contributors

sandervandevelde avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.