【发布时间】:2021-05-21 00:26:24
【问题描述】:
一个很好的例子是 vnet 资源中的子网声明。我可以通过这种 ARM 语法将子网添加到 vnet
//vnet declaration with subnet declaration in subnets arrary
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-11-01",
"name": "vnetName",
...
"properties": {
"subnets": [
"name": "subnetName",
"properties": {
...
}
],
}
}
我也可以像这样在 vnet 声明之外添加它:
//vnet declaration w/out subnet
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-11-01",
"name": "vnetName",
...
"properties": {
...
}
}
//separate subnet declaration as specific type outside of vnet declaration, but dependsOn vnet
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2020-11-01",
"name": "subnetName",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', 'vnetName')]"
],
"properties": {
...
}
}
在这方面的快速 google 让我进入了这个 Microsoft documentation 页面,该页面向您展示了如何通过在父资源中嵌套资源数组而不使用子网数组来做到这一点。
如果需要在 vnet 声明中以及在 vnet 声明之外将同一个子网声明为自己的类型,我想知道 b/c 需要什么,这给 ARM 模板增加了很多冗长。
谢谢!
【问题讨论】:
标签: azure azure-resource-manager arm-template