使用property iteration,我们可以在ARM资源中增加属性。但是,如何将这些复制的属性与其他显式键入的属性混合? 我所期望的可能像此片段一样(当然,这是不正确的,因为“ probes”属性已重复)。
"probes": [
{
"name": "FirstProbe",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": 123,
"protocol": "Tcp"
}
},
{
"name": "SecondProbe",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": 456,
"protocol": "Tcp"
}
}
],
"copy": [
{
"name": "probes",
"count": "[length(parameters('someParam'))]",
"input": {
"name": "[concat('OtherProbe', parameters('someParam')[copyindex('probes')])]",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": "[parameters('someParam')[copyindex('probes')]]",
"protocol": "Tcp"
}
}
}
]
因此,在这种情况下,我需要明确定义前两个探针(FirstProbe和SecondProbe),但我还需要基于someParam数组值添加更多探针。
答案 0 :(得分:1)
您只需要这样做:
"variables": {
"probes-static": [
{
"name": "FirstProbe",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": 123,
"protocol": "Tcp"
}
},
{
"name": "SecondProbe",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": 456,
"protocol": "Tcp"
}
}
],
"copy": [
{
"name": "probes-loop",
"count": "[length(parameters('someParam'))]",
"input": {
"name": "[concat('OtherProbe', parameters('someParam')[copyindex('probes')])]",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": "[parameters('someParam')[copyindex('probes')]]",
"protocol": "Tcp"
}
}
}
],
"probes": "[concat(variables('probes-static'), variables('probes-loop'))]"
}
然后您可以使用variable('probes')
作为结果并将其分配给LB属性