question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment Variables in deployment.template.json

See original GitHub issue

Expected Behavior

"modules": {
          "MODULE-NAME": {
            "version": "1.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "env": {
              "VAR": {
                "value": "$VAR"
              },
              "VAR_ONE": {
                "value": "${VAR}"
              },
              "VAR_TWO": {
                "value": "$(VAR)"
              }
            },
            "settings": {
              "image": "some-image",
              "createOptions": {
                "Env": [
                  "VAR=$VAR",
                  "VAR_ONE=${VAR}",
                  "VAR_TWO=$(VAR)"
                ]
              }
            }
          }
        }

The expected behaviour is that the deployment template can pick environmental variables when they are requested from either the env for the iot module OR from Env in the create options for the docker container. However, neither of these options work.

Current Behavior

References to environment variables are treated as string values

Steps to Reproduce

Use the sample module template referenced in the Expected Behavior section

Context (Environment)

IoT Edge Simulator running on VSCode

Device (Host) Operating System

MacOSX

Container Operating System

node:lts-alpine

Runtime Versions

Version - 1.0.8.1.24554792

iotedged

Version - 1.0.8.1.24554792

Edge Agent

1.0.0

Edge Hub

1.0.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Gordonbycommented, Jan 12, 2021

Is there not a feature request here @arsing / @DoychinDoychev ?

I’m authoring a deployment.template.json file, and wanting to make use of variables in the .env file as described in this issue, and as already implemented for the CONTAINER_REGISTRY_USERNAME and CONTAINER_REGISTRY_PASSWORD variables in the .env file. The ability to make use of the existing templating build when “Generate IoT Edge Deployment Manifest” would be great, rather than the suggestion of using another templating engine for the new variables.

0reactions
heikki0commented, Aug 10, 2022

@Gordonby, now when you mention feature requests, it would be helpful that one could use environment variables with some kind of simple logic so that one could at least combine strings, lets say VAR1=foo VAR2=bar and in the process of converting “${VAR1+VAR2}” from the template to the config file it would yield “foobar”. Similarly that many .js templates do.

Where one could discuss such a request? Thanks a lot with any guidance!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Variables in azure iot edge deployment template
In Azure Iot edge deployment template json, I see a variables named MODULES.SampleModule or MODULES.SampleModule.json . An example is at this ...
Read more >
Variables in templates - Azure Resource Manager
This article describes how to define and use variables in your Azure Resource Manager template (ARM template). You use variables to simplify ...
Read more >
Template functions - deployment - Azure Resource Manager
You can use deployment() to link to another template based on the URI of the parent template. JSON Copy. "variables": { ...
Read more >
Adding Environment Variables to an ARM template for Azure ...
Environment variables can be created at the same time as the app service by adding another resource to the ARM template. I like...
Read more >
Using environment variables in ARM templates to deploy IaC
There are many of ways to deploy IaC environments from a single source code. This Quick Tip combines parameters and variables in ARM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found