Azure ARM 模板 - 将数组复制到对象数组
Azure ARM template - copy array to object array
我的 ARM 模板正在尝试将 IP 地址的字符串数组转换为包含对象的数组。
ARM 模板最终应该如下所示:
"ipRules": [
{
"value": "1.1.1.1",
"action": "Allow"
},
{
"value": "1.1.1.2",
"action": "Allow"
},
]
所以为了得到像上面那样的对象表示法,我尝试使用 Copy 函数创建一个新变量来迭代原始 Ip 数组:
"convertedAllowedIps": {
"copy": [
{
"count": 2,
"input": {
"value": "[variables('allowedIps')[copyIndex()]]",
"action": "Allow"
}
}
]
}
我是这样分配的:
"ipRules": "[variables('convertedAllowedIps')]",
这会导致 'The language expression property could not be evaluated' 错误。我在这里做错了什么?
复制函数如下所示:
"convertedAllowedIps": {
"copy": [
{
"name": "something",
"count": 2,
"input": {
"value": "[variables('allowedIps')[copyIndex('something')]]",
"action": "Allow"
}
}
]
}
然后你会像这样引用它:
"[variables('convertedAllowedIps').something]"
我的 ARM 模板正在尝试将 IP 地址的字符串数组转换为包含对象的数组。
ARM 模板最终应该如下所示:
"ipRules": [
{
"value": "1.1.1.1",
"action": "Allow"
},
{
"value": "1.1.1.2",
"action": "Allow"
},
]
所以为了得到像上面那样的对象表示法,我尝试使用 Copy 函数创建一个新变量来迭代原始 Ip 数组:
"convertedAllowedIps": {
"copy": [
{
"count": 2,
"input": {
"value": "[variables('allowedIps')[copyIndex()]]",
"action": "Allow"
}
}
]
}
我是这样分配的:
"ipRules": "[variables('convertedAllowedIps')]",
这会导致 'The language expression property could not be evaluated' 错误。我在这里做错了什么?
复制函数如下所示:
"convertedAllowedIps": {
"copy": [
{
"name": "something",
"count": 2,
"input": {
"value": "[variables('allowedIps')[copyIndex('something')]]",
"action": "Allow"
}
}
]
}
然后你会像这样引用它:
"[variables('convertedAllowedIps').something]"