rk92
rk92

Reputation: 593

Passing a pipeline variable into ARM template

I am looking to take a name in a text file, set it as a variable, and then pass this variable into an ARM template so that when a resource is deployed it includes the name from the text file.

Currently my YAML file is set to start with a PS command for setting a variable and reading the text file within my repository.

After that I have an ARM template deployment for an SQL server and would like to pass the set variable of the client name into the template so that the SQL server name includes the variable.

Would I need to add a variable field into the template and if so how do I link the PS/pipeline variable into there?

Upvotes: 0

Views: 3315

Answers (1)

Leo Liu
Leo Liu

Reputation: 76670

Would I need to add a variable field into the template and if so how do I link the PS/pipeline variable into there?

We could create a parameter in the ARM template and then pass the variable clientname as a parameter when we use the Azure Resource Group Deployment task:

Write-Host ("##vso[task.setvariable variable=clientname]clientnameValue")

The ARM template file deploy.json:

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

The ARM template deployment task:

enter image description here

You could check this document Using linked and nested templates when deploying Azure resources and this blog for some more details.

Upvotes: 2

Related Questions