强制对资源执行标记的Azure策略

时间:2020-02-27 09:38:12

标签: azure tags required

我需要一些帮助

上下文: 为一家公司希望在创建的每个资源上加上标签(他们要求我提供服务)的公司工作,该资源必须由该资源的创建者的电子邮件(或身份)标记 我正在使用此内置政策,希望您的帮助进行调整

{
  "properties": {
    "displayName": "Require tag and its value",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Enforces a required tag and its value. Does not apply to resource groups.",
    "metadata": {
      "version": "1.0.1",
      "category": "Tags"
    },
    "parameters": {
      "tagName": {
        "type": "String",
        "metadata": {
          "displayName": "Tag Name",
          "description": "Name of the tag, such as 'environment'"
        }
      },
      "tagValue": {
        "type": "String",
        "metadata": {
          "displayName": "Tag Value",
          "description": "Value of the tag, such as 'production'"
        }
      }
    },
    "policyRule": {
      "if": {
        "not": {
          "field": "[concat('tags[', parameters('tagName'), ']')]",
          "equals": "[parameters('tagValue')]"
        }
      },
      "then": {
        "effect": "deny"
      }
    }
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "1e30110a-5ceb-460c-a204-c1c3969c6d62"
}

我是Azure和脚本的新手,非常感谢您的帮助

最诚挚的问候

0 个答案:

没有答案