【发布时间】:2020-08-14 06:53:57
【问题描述】:
我正在使用 Azure DevOps Pipelines 部署 ARM 模板。我的模板有一个 tags 参数,我使用 AzureResourceManagerTemplateDeployment@3 传递到管道中。
我的 ARM 模板在参数部分中有一个值作为对象。 tags 是一个对象,这是许多示例模板所显示的:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceName": {
"type": "string",
"metadata": {
"description": "Specifies the name of the resource, including its prefix."
}
},
"tags": {
"type": "object",
"defaultValue": {
"Cost Center": "Admin"
}
}
},
"resources": [
{
"apiVersion": "2019-06-01",
"kind": "StorageV2",
"location": "[resourceGroup().location]",
"name": "[parameters('resourceName')]",
"properties": {
"supportsHttpsTrafficOnly": true
},
"sku": {
"name": "Standard_LRS"
},
"type": "Microsoft.Storage/storageAccounts",
"tags": "[parameters('tags')]"
}
]
}
[编辑以匹配后面的线程]
我正在使用ubuntu-latest 作为我的游泳池。标签可能有空格。
在我的 simplicity 管道中,我将标签设置为一个变量。
pool:
vmImage: 'ubuntu-latest'
variables:
- name: tags
value: ("Location Region=West US 2" "Environment=${{ parameters.environment }}")
当我调用模板部署时,我将标签作为overrideParameters 传递给
- task: AzureResourceManagerTemplateDeployment@3
displayName: "Deploy my templateaccount"
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'ResourceManager-connection'
subscriptionId: ${{ parameters.subscriptionid }}
action: 'Create Or Update Resource Group'
resourceGroupName: '$(resourceGroupName)'
location: '${{ parameters.location }}'
templateLocation: 'Linked artifact'
csmFile: 'mytemplatelocation/azuredeploy.json'
overrideParameters: -resourceName abcdefg76534 -tags "$(tags)"
deploymentMode: 'Incremental'
deploymentOutputs: resourceOutput
- pwsh: Write-Output '$(resourceOutput)'
到目前为止,我还不明白 Ubuntu 上的 AzureResourceManagerTemplateDeployment@3 是如何期望发送标签的。
在每种情况下,模板都无法部署。
Azure DevOps Pipeline 是否支持此方案?
有人有建议吗?
【问题讨论】:
-
你能分享你收到的错误吗?
-
错误是##[error]部署模板验证失败:'模板参数JToken类型无效。预期的“对象”。实际的“字符串”。请参阅aka.ms/resource-manager-parameter-files 了解使用详情。'.
标签: azure azure-devops