我想同时部署一些ARM模板,并在部署模板(mainTemplate.json)中使用“relativePath”。
我正在 VScode 上编写部署模板,但它会出现以下错误,其中“parametesLink”的“relativePath”。
Missing required property "uri"
我在 Microsoft 的parametersLink 文档中没有看到任何提及“relativePath”,但是我不能使用它吗?
所有模板和参数文件都在本地目录中,我在开发时使用 Windows PowerShell。
任何答案都会有所帮助。谢谢你。
mainTemplates.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"env":{
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2022-09-01",
"name": "storage",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "linked/storage/linkedtemplate_idbridge_base_storage.json"
},
"parametersLink": {
"relativePath": "[concat('linked/storage/linkedtemplate_idbridge_base_storage.parameters-', parameters('env'),'.json')]"
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2022-09-01",
"name": "monitoring",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "linked/monitoring/linkedtemplate_idbridge_base_monitoring.json"
},
"parametersLink": {
"relativePath": "[concat('linked/monitoring/linkedtemplate_idbridge_base_monitoring.parameters-', parameters('env'), '.json')]"
}
}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2022-09-01",
"name": "notification",
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "linked/notification/linkedtemplate_idbridge_base_notification.json"
},
"parametersLink": {
"relativePath": "[concat('linked/notification/linkedtemplate_idbridge_base_notification.parameters-', parameters('env'), '.json')]"
}
}
}
]
}
部署链接模板时不可能使用“relativePath”作为“parametersLink”
根据 Microsoftdoc,参数链接 要求
uri
提及参数文件的位置,此 relative path
不支持。
而 TemplateLink 根据 Microsoftdoc,此支持
uri
和 absolute path
提及链接模板的位置。
根据要求进行必要更改的示例配置。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
.
.
.
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "linked/storage/linkedtemplate_idbridge_base_storage.json"
},
"parametersLink": {
"uri": "[concat('https://yourstorageaccount.blob.core.windows.net/templates/linked/storage/linkedtemplate_idbridge_base_storage.parameters-', parameters('env'), '.json')]"
}
}
},
{
"type": "Microsoft.Resources/deployments",
.
.
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "linked/monitoring/linkedtemplate_idbridge_base_monitoring.json"
},
"parametersLink": {
"uri": "[concat('https://yourstorageaccount.blob.core.windows.net/templates/linked/monitoring/linkedtemplate_idbridge_base_monitoring.parameters-', parameters('env'), '.json')]"
}
}
},
{
"type": "Microsoft.Resources/deployments",
.
.
"properties": {
"mode": "Incremental",
"templateLink": {
"relativePath": "linked/notification/linkedtemplate_idbridge_base_notification.json"
},
"parametersLink": {
"uri": "[concat('https://yourstorageaccount.blob.core.windows.net/templates/linked/notification/linkedtemplate_idbridge_base_notification.parameters-', parameters('env'), '.json')]"
}
}
}
]
}
尝试将
relativePath
中的 parametersLink
替换为指向参数文件的 uri
。
参考: