似乎 azure 处理嵌套的模板依赖项,如果找不到资源则失败。
例如,我有 3 个嵌套模板:
- 模板 #1:创建 VNet 和 Private-DNS-Zone。
- 模板 #2:创建 Nic(可能带有 vm)
- 模板 #3:为 DNS 区域中的 Nic 添加 A-Record。
模板 Json:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"apiVersion": "2017-05-10",
"name": "VnetTemplate",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"properties":{
"subnets":[
{
"properties":{
"addressPrefix":"10.0.0.0/24"
},
"name":"default"
}
],
"addressSpace":{
"addressPrefixes":[
"10.0.0.0/24"
]
}
},
"type":"Microsoft.Network/virtualNetworks",
"location":"[resourceGroup().location]",
"name":"my_vnet",
"apiVersion":"2017-10-01"
},
{
"properties":{
"resolutionVirtualNetworks":[
{
"id":"[resourceId('Microsoft.Network/virtualNetworks/','my_vnet')]"
}
],
"zoneType":"Private"
},
"type":"Microsoft.Network/dnsZones",
"location":"global",
"dependsOn":["my_vnet"],
"name":"my.dns",
"apiVersion":"2017-10-01"
}
]
}
}
},
{
"apiVersion": "2017-05-10",
"name": "NicTemplate",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"properties":{
"ipConfigurations":[
{
"properties":{
"privateIPAllocationMethod":"Dynamic",
"subnet":{
"id":"[resourceId('Microsoft.Network/virtualNetworks/subnets', 'my_vnet', 'default')]"
}
},
"name":"app_vnic_IPConf"
}
]
},
"type":"Microsoft.Network/networkInterfaces",
"location":"[resourceGroup().location]",
"name":"app_vnic",
"apiVersion":"2017-10-01"
}
]
}
},
"dependsOn":[
"VnetTemplate"
]
},
{
"apiVersion": "2017-05-10",
"name": "DnsRecordTemplate",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"properties":{
"TTL":3600,
"ARecords":[
{
"ipv4Address":"[reference(resourceId('Microsoft.Network/networkInterfaces/','app_vnic'), '2017-10-01').ipConfigurations[0].properties.privateIPAddress]"
}
]
},
"type":"Microsoft.Network/dnsZones/A",
"name":"my.dns/my_app",
"apiVersion":"2017-10-01"
}
]
}
},
"dependsOn": [
"NicTemplate"
]
}
]
}
我希望在前两个完成之前不会处理最后一个嵌套模板,但事实并非如此。
(这个例子简化了我在多个资源组上部署的更大模板的问题)
知道如何处理吗?