我在编辑政策时缺少什么

问题描述 投票:0回答:1

我只是尝试采用默认的拒绝模板并添加一些我想要添加到资源中的标签。我收到一条错误消息,指出不允许“tagName1”。我错过了什么?

{
"mode": "All",
"policyRule": {
"if": {
  "allOf": [
    {
      "field": "type",
      "equals": "Microsoft.Resources/subscriptions/resourceGroups"
    },
    {
      "field": "[concat('tags[', parameters('tagName'),('tagName1') ']')]",
      "exists": "false"
    }
  ]
},
"then": {
  "effect": "deny"
}
},
"parameters": {
"tagName": {
  "type": "String",
  "metadata": {
    "displayName": "Tag Name",
    "description": "Name of the tag, such as 'environment'"
  },
  "tagName1": {
  "type": "String",
  "metadata": {
    "displayName": "Project",
    "description": "Name of the tag, such as 'environment'"
  }
},
azure azure-policy
1个回答
0
投票

您只是在 tagName 之后缺少一个右大括号。

{
"mode": "All",
"policyRule": {
"if": {
  "allOf": [
    {
      "field": "type",
      "equals": "Microsoft.Resources/subscriptions/resourceGroups"
    },
    {
      "field": "[concat('tags[', parameters('tagName'),('tagName1') ']')]",
      "exists": "false"
    }
  ]
},
"then": {
  "effect": "deny"
}
},
"parameters": {
  "tagName": {
    "type": "String",
    "metadata": {
      "displayName": "Tag Name",
      "description": "Name of the tag, such as 'environment'"
    }
  },
  "tagName1": {
    "type": "String",
    "metadata": {
      "displayName": "Project",
      "description": "Name of the tag, such as 'environment'"
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.