Azure ARM:解决方案模板:多个虚拟机:如何在没有硬编码IP的情况下配置后端地址数组的内容
我尝试在中使用RTFM,但是Azure ARM:解决方案模板:多个虚拟机:如何在没有硬编码IP的情况下配置后端地址数组的内容,azure,azure-application-gateway,azure-template,Azure,Azure Application Gateway,Azure Template,我尝试在中使用RTFM,但是101应用程序网关中的示例都没有显示这种模式。我有一个部署N个VM的解决方案模板ARM模板。我需要为Azure应用程序网关设置并配置引用这些N个VM的后端地址。我熟悉copy和copyIndex()模式,但我不知道如何在这里应用它。示例的代码如下所示: "backendAddressPools": [ { "name": "appGatewayBackendPool", "properties": { "
101应用程序网关中的示例都没有显示这种模式。我有一个部署N个VM的解决方案模板ARM模板。我需要为Azure应用程序网关设置并配置引用这些N个VM的后端地址。我熟悉copy
和copyIndex()
模式,但我不知道如何在这里应用它。示例的代码如下所示:
"backendAddressPools": [
{
"name": "appGatewayBackendPool",
"properties": {
"BackendAddresses": [
{
"IpAddress": "[parameters('backendIpAddress1')]"
},
{
"IpAddress": "[parameters('backendIpAddress2')]"
}
]
}
}
],
但我想做一些类似的事情:
"backendAddressPools": [
{
"name": "appGatewayBackendPool",
"properties": {
"BackendAddresses": [
{
"IpAddress": "[concat(variables('managedVMPrefix'), copyIndex(),variables('nicName'))]"
}
]
}
}
],
我确信这行不通,因为我需要在BackendAddressess
数组中输入N个条目
有什么办法吗
谢谢
Ed查看后,我意识到这是正确的语法:
"backendAddressPools": [
{
"name": "appGatewayBackendPool",
"properties": {
"copy": [{
"name": "BackendAddresses",
"count": "[parameters('numberOfInstances')]",
"input": {
"IpAddress": "[reference(concat(variables('managedVMPrefix'), copyIndex('BackendAddresses', 1), variables('publicIPAddressName'))).properties.ipAddress]"
}
}]
}
}
]
给定NumberOfInstances
为3和引用(concat(变量('managedVMPrefix')、copyIndex('BackendAddresses')、变量('nicName'))
解析为mspVM1publicIp
,mspVM2publicIp
,其本身通过引用()
函数产生10.0.1.10
,10.0.1.11
,10.0.1.12
,这将产生以下输出:
"backendAddressPools": [
{
"name": "appGatewayBackendPool",
"properties": {
"BackendAddresses": [
{
"IpAddress": "[10.0.1.10]"
},
{
"IpAddress": "[10.0.1.11]"
},
{
"IpAddress": "[10.0.1.12]"
}
]
}
}
我必须说,我认为ARM模板语法非常难以使用、理解和维护,但如果有更多的经验,它可能会变得更容易。这个问题还有什么更新吗?它能解决你的问题吗?如果是,请接受。