简体   繁体   English

将管道变量传递到 ARM 模板

[英]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.

相关问题 将 ARM 模板输出作为管道变量传递给 Azure powershell 任务时出现问题 - Issue while passing ARM template outputs as a pipeline variable to Azure powershell task 将变量从ARM模板传递到PowerShell - Passing a variable from ARM Template to PowerShell Powershell为Azure数据工厂管道下载ARM模板 - Powershell to download ARM template for Azure data factory Pipeline ARM 模板 - 使用 Powershell 传递参数并使用 Secret 值 - ARM Template - Passing parameters with Powershell AND use Secret values 使用DSC和ARM模板传递凭据以及使用Visual Studio 2017进行部署 - Passing Credentials using DSC and ARM Template and Deploying with Visual Studio 2017 在为 ARM 模板部署创建的 Azure DevOps Pipeline 中找不到 JSON 文件路径 - Unable to find the JSON file path in Azure DevOps Pipeline which is created for ARM template deployment 将管道变量作为参数传递到 Powershell 构建步骤在 Azure DevOps 中不起作用 - passing pipeline variable as argument into Powershell build step not working in Azure DevOps 将 arm 参数传递给 Microsoft.VirtualMachineImages/imageTemplates 模板的 powershell 自定义部分 - passing arm parameters to a powershell customize section of a Microsoft.VirtualMachineImages/imageTemplates template Azure ARM - 使用 ARM 模板的基线资源 - Azure ARM - Baseline resources with ARM template Azure 管道:当“条件:成功()”在参数中时,将参数传递给模板不起作用 - Azure pipeline: Passing parameters to a template does not work when "condition: succeeded()" is in parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM