Reputation: 11201
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.
MODULES.SampleModule
populated?Upvotes: 3
Views: 1404
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
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