kiranpradeep
kiranpradeep

Reputation: 11201

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 link. There is JSON schema at iotedge repository. But I am not able to find a reference documentation for the variables that could be used in an azure deployment template json.

  1. From where is the variable MODULES.SampleModule populated?
  2. Is there a reference documentation for azure deployment template variables?

Upvotes: 3

Views: 1404

Answers (2)

MaxThom
MaxThom

Reputation: 1401

For the deployment template, every variable must be in this syntax ${var_name}. When running the deployment file generation, the variables will be replace by the host environment variable with the same name.

For example, I have ${CONTAINER_REGISTRY_USERNAME} and ${CONTAINER_REGISTRY_PASSWORD} in my deployment.template.json. On my host machine I have, CONTAINER_REGISTRY_USERNAME and CONTAINER_REGISTRY_PASSWORD set has environment variable. When the task is run, they are replaced.

To make it work in a pipeline, you must add the environnement variables on the host machine. In AzureDevOps, you must create a library (https://learn.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&tabs=yaml).

In your pipeline, you can use this task to make the generation :

- task: AzureIoTEdge@2
  displayName: 'Generate deployment manifest - amd64'
  inputs:
     action: 'Generate deployment manifest'
     templateFilePath: 'EdgeModule/deployment.template.json'
     defaultPlatform: 'amd64'
     deploymentManifestOutputPath: '$(System.DefaultWorkingDirectory)/config/deployment-amd64.json'
     validateGeneratedDeploymentManifest: 'true'
     fillRegistryCredential: 'true'

I have a github project with a default iotedge template including a full pipeline for unit test, code coverage, build and push image, generate deployment manifest and deploy to iothub.

https://github.com/MaxThom/IoTEdgeModule-Template

Good luck :)

Upvotes: 2

Mark Radbourne
Mark Radbourne

Reputation: 643

This project was built with the Visual Studio Code IoT Edge extension (https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools). It is the template that is used to generate the actual IoT Edge deployment file. When the extension creates the deployment file from this template it will substitute those variables with the required values. This is an implementation detail that is not exposed and thus undocumented.

Upvotes: 0

Related Questions