ARM模板的文档没有说明如何使用不同的版本(至少我可以找到)。我从文档中得到的是contentVersion
和templateLink
对象中的parameterLink
值需要与链接模板中的值匹配。
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "linkedTemplate",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json",
"contentVersion":"1.0.0.0"
},
"parametersLink": {
"uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.parameters.json",
"contentVersion":"1.0.0.0"
}
}
}
]
有人在GitHub上打开了一个问题,要求提供更多信息,但我仍然没有清楚了解如何使用该版本。 https://github.com/MicrosoftDocs/azure-docs/issues/9402
有谁知道如何使用不同的contentVersion
值的任何例子?
我认为您可能会误解contentVersion
的用法,该属性仅用于记录模板中的更改并确保您使用的是正确的模板,它可以是任何值。
例如,如果模板contentVersion
中的https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json
是2.0.0.0
,
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"parameters": {},
"resources": []
}
但你使用下面的"contentVersion":"1.0.0.0"
,
"templateLink": {
"uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json",
"contentVersion":"1.0.0.0"
}
然后你会得到一个错误。在这个link中已经提到过:
您不必为模板或参数提供
contentVersion
属性。如果您未提供内容版本值,则会部署当前版本的模板。如果为内容版本提供值,则它必须与链接模板中的版本匹配;否则,部署失败并显示错误。
有一天,如果您对目标模板进行了一些更改,您可以将contentVersion
更改为3.0.0.0
以记录更改等。或者您不要更改它。这一切都取决于你。