arrays - Azure ARM 模板 - 将数组复制到对象数组

标签 arrays azure azure-rm-template

我的 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')]",

这会导致“无法评估语言表达式属性”错误。我在这里做错了什么?

最佳答案

复制功能如下所示:

"convertedAllowedIps": {
  "copy": [
      {
        "name": "something",
        "count": 2,
        "input": {
          "value": "[variables('allowedIps')[copyIndex('something')]]",
          "action": "Allow"
      }
    }
  ]  
}

然后你可以像这样引用它:

"[variables('convertedAllowedIps').something]"

关于arrays - Azure ARM 模板 - 将数组复制到对象数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49629408/

相关文章:

ios - 无法从数组中删除元素

从 Web 门户监控 Azure 存储

java - 使用 ByteBuffer 处理 byte[]

arrays - 是否可以在 Perl foreach 循环中分配两个变量?

azure - 尝试在 Azure 数据工厂中进行 Catch

azure - CosmosDb 防火墙、Azure IP 地址

azure - 如何使用 Azure DevOps 发布变量将环境特定值传递到 azure 数据工厂中的管道参数

azure - 如何预先检测Azure ARM脚本是否会更改customData?

c# - 使用 C# 查询 MongoDB 嵌套数组文档

c# - 使用 AAD 帐户以外的 ms live 帐户时,Azure AD 身份验证失败