【问题标题】:Azure mandatory TagAzure 强制标记
【发布时间】:2021-12-30 13:20:45
【问题描述】:

帮助我使用 azure 策略制作强制标签,并且不允许用户提供自己的标签名称。以下代码强制提及的标签,而不是控制不允许的其他标签

{   
  "mode": "All",   
  "policyRule": {   
    "if": {  
      "anyOf": [  
        {  
          "field": "tags['environment']",  
          "exists": "false"  
        },  
        {  
          "field": "tags['Location']",  
          "exists": "false"  
        }  
      ]  
    },  
    "then": {  
      "effect": "deny"  
    }  
  },  
  "parameters": {}   
}  
  

【问题讨论】:

标签: azure tags policy


【解决方案1】:

这是在 Azure Policy 中使用标记进行更改的示例

"policyRule": {
    "if": {
        "allOf": [{
            "field": "type",
            "equals": "Microsoft.Resources/subscriptions/resourceGroups"
        },
        {
            "field": "name",
            "like": "prd-*"
        },
        {
            "field": "tags['Env']",
            "notEquals": "Production"
        }

    ]
    },
    "then": {
        "effect": "modify",
        "details": {
            "roleDefinitionIds": [
                "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
            ],
            "operations": [{
                "operation": "addOrReplace",
                "field": "tags['Env']",
                "value": "Production"
            }]
        }
    }
}

如需更多信息,请查看Azure Policy 文档

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多