2
votes

When I build a docker image I use the buildID as tag for the image. I then deploy the docker image in a Azue WebApp for Docker via a ARM template. I use VSTS build to build and push the image and I use a VSTS release to deploy the Azure WebApp for containers.

I don't want to put the buildID hardcoded in the ARM template, but I am looking for a way to somehow refer to the buildID variable in the ARM template.

Anyone any ideas?

2

2 Answers

2
votes

It's worth spending some time reviewing this https://docs.microsoft.com/en-us/vsts/build-release/concepts/definitions/release/variables?view=vsts&tabs=batch if you haven't come across this before.

As long as the docs are correct, to do this first create a parameter in your ARM template and check this in to git.

In your vsts release, create a variable, called "BuildID" or "Build Number" depending on which value you actually want and assign it the value $(Build.BuildId/BuildNumber). Then pass this parameter to your ARM template and it should work by picking up the build id from the build artefact.

NB. this is my first every post so any feedback welcome :)

3
votes

You can always pass parameter to a template file. It will look like:

deploy.json

...
"parameters": {
    "BuildNumber": {
      "type": "string"
    }
}
...

And then in VSTS step you yust set this parameter:

enter image description here