【问题标题】:Azure Policy: Tag defines if a resource can be moved/deployed to a specific locationAzure Policy:标签定义资源是否可以移动/部署到特定位置
【发布时间】:2021-03-25 08:48:55
【问题描述】:

我正在尝试根据 Azure 策略的标记(标记名称为“测试”且标记值为“是”)何时阻止资源创建/迁移到特定区域之外的其他区域。到现在为止我得到了这个,但是当我分配它时,当新资源具有特定标签时,仍然可以在其他位置创建资源。此外,Azure 告诉我 if “需要一个来源并且存在”。有什么想法有什么问题吗?

    {
  "mode": "Indexed",
  "policyRule": {
    "if": {
      "AllOf": [
        {
          "field": "tags['test']",
          "exists": "true"
        },
        {
          "value": "tags['test']",
          "equals": "yes"
        },
        {
          "field": "location",
          "notIn": [
            "France Central",
            "France South",
            "North Europe",
            "West Europe"
          ]
        }
      ]
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {}
}

谢谢!

【问题讨论】:

    标签: json azure


    【解决方案1】:

    看来我找到了答案:

    {
      "if": {
        "AllOf": [
          {
            "field": "tags['test']",
            "exists": "true"
          },
          {
            "field": "tags['test']",
            "equals": "yes"
          },
          {
            "field": "location",
            "notIn": [
              "France Central",
              "France South",
              "North Europe",
              "West Europe"
            ]
          }
        ]
      },
      "then": {
        "effect": "deny"
      }
    }
    

    基本上,“值”字必须是“字段”字。

    【讨论】:

      猜你喜欢
      • 2015-03-06
      • 1970-01-01
      • 1970-01-01
      • 2020-07-03
      • 2021-05-15
      • 2021-06-23
      • 2021-01-02
      • 2023-01-29
      • 2017-03-10
      相关资源
      最近更新 更多