简体   繁体   中英

Azure policy - "deny" subscription creation if certain tags are not set

I have created the azure policy below but I am still able to create new subscriptions. The same if conditions are used in an Azure BuiltIn definition that modifies-adds tags to subscriptions. Any hints?

{
  "mode": "All",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Resources/subscriptions"
        },
        {
          "field": "[concat('tags[', parameters('tagName'), ']')]",
          "exists": "false"
        }
      ]
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {
    "tagName": {
      "type": "String",
      "defaultValue": "CostCenter"
    }
  }
}

Just got an answer from Microsoft Support. It seems this is the current design that applies only to subscriptions being created from the portal. If the subscription is deployed programatically, the policy does its job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM