[英]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.我希望在文本文件中取一个名称,将其设置为变量,然后将此变量传递给 ARM 模板,以便在部署资源时它包含文本文件中的名称。
Currently my YAML file is set to start with a PS command for setting a variable and reading the text file within my repository.目前,我的 YAML 文件设置为以 PS 命令开始,用于设置变量并读取我的存储库中的文本文件。
task: PowerShell@2
inputs:
targetType: 'inline'
script: 'Get-Content -Path $(Build.Repository.LocalPath)/ClientListTest.txt;Write-Host "##vso[task.setvariable variable=clientname]"'
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.之后,我有一个 SQL 服务器的 ARM 模板部署,并希望将客户端名称的设置变量传递到模板中,以便 SQL 包含该变量。
Would I need to add a variable field into the template and if so how do I link the PS/pipeline variable into there?我是否需要在模板中添加一个变量字段,如果需要,我如何将 PS/管道变量链接到那里?
Would I need to add a variable field into the template and if so how do I link the PS/pipeline variable into there?
我是否需要在模板中添加一个变量字段,如果需要,我如何将 PS/管道变量链接到那里?
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:我们可以在 ARM 模板中创建一个参数,然后在使用Azure 资源组部署任务时将变量
clientname
作为参数传递:
Write-Host ("##vso[task.setvariable variable=clientname]clientnameValue")
The ARM template file deploy.json
: ARM 模板文件
deploy.json
:
...
"parameters": {
"clientname": {
"type": "string"
}
}
...
The ARM template deployment task: ARM模板部署任务:
You could check this document Using linked and nested templates when deploying Azure resources and this blog for some more details.您可以在部署 Azure 资源和此博客时查看此文档使用链接和嵌套模板了解更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.