gpt4 book ai didi

Azure ARM 模板部署

转载 作者:行者123 更新时间:2023-12-03 02:57:00 24 4
gpt4 key购买 nike

我正在尝试通过Azure ARM模板为VM创建NIC卡。但我的脚本还创建了连接 NIC 到应用程序网关的功能。但到目前为止我只创建虚拟机和网卡。是否有条件跳过App网关和NIC的串联。下面是网卡创建模板:

{
"comments": "NIC_Creation",
"tags": {
"owner": "[parameters('owner')]"
},
"condition": "[equals(parameters('CreateVM'), 'yes')]",
"dependsOn": [
// "[resourceId('Microsoft.Network/publicIPAddresses', parameters('VM_PublicIP_Name'))]",
// "[resourceId('Microsoft.Network/virtualNetworks', parameters('VNET_Name'))]",
"[resourceId('Microsoft.Network/publicIPAddresses', parameters('VM_PublicIP_Name'))]",
"[resourceId('Microsoft.Network/virtualNetworks', parameters('VNET_Name'))]",
"[resourceId('Microsoft.Network/networkSecurityGroups', parameters('NSG_Name'))]",
"[resourceId('Microsoft.Network/applicationGateways', parameters('AppGateWay_Name'))]"

],
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('NIC_Name')]",
"apiVersion": "2018-02-01",
"location": "[parameters('myvmlocation')]",
"scale": null,
"properties": {
"provisioningState": "Succeeded",
"resourceGuid": "e319fe3b-4162-4501-81e7-b657be52f411",
"ipConfigurations": [
{
"name": "ipconfig1",
"etag": "W/\"a9185125-7a6e-4811-ae29-4afe520e7c4f\"",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "192.168.1.4",//192.168.1.4 //172.19.0.5
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('VM_PublicIP_Name'))]"
},
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks', parameters('VNET_Name')), '/subnets/',parameters('subnetname'))]"
},
"primary": true,
"privateIPAddressVersion": "IPv4",
"applicationGatewayBackendAddressPools": [

{
"condition": "[equals(parameters('CreateAppgateway'), 'yes')]",
"id": "[concat(resourceId('Microsoft.Network/applicationGateways', parameters('AppGateWay_Name')), '/backendAddressPools/sxBackendPool')]"
},
{
"condition": "[equals(parameters('CreateAppgateway'), 'yes')]",
"id": "[concat(resourceId('Microsoft.Network/applicationGateways', parameters('AppGateWay_Name')), '/backendAddressPools/nxBackendPool')]"
}
]
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": []
},
"macAddress": "00-0D-3A-1F-51-61",
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('NSG_Name'))]"
},
"primary": true
}
},

我在 applicationGatewayBackendAddressPools 中添加了一个条件,但它不起作用。任何人都可以帮助我吗?

最佳答案

不可以,您不能对单个属性设置条件。您可以做的是将 if() 函数与变量和 json() 函数一起使用来计算所需的结果

"applicationGatewayBackendAddressPools": "[if(equals(parameters('CreateAppgateway'), 'yes'), variables('applicationGateways'), json('null'))]"

关于Azure ARM 模板部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52202517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com