json - 如何在 Azure 策略中强制实现标签值模式?

标签 json azure azure-rm-template azure-policy policies

我想对资源组所需的标签强制执行标签值模式“RJGVM-###”。 我设法使其成为必需的,但每当我输入任何值时,它仍然会通过。

{
  "mode": "All",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Resources/subscriptions/resourceGroups"
        },
        {
          "not": {
            "field": "[concat('tags[',parameters('tagName'), ']')]",
            "exists": "true"
          }
        },
        {
          "value": "[resourceGroup().tags[parameters('tagName')]]",
          "notMatch": "RJGVM-###"
        }
      ]
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {
    "tagName": {
      "type": "String",
      "metadata": {
        "displayName": "Tag Name",
        "description": "Name of the tag, such as 'environment'"
      }
    }
  }
}

最佳答案

请引用以下链接中提到的示例,以确保标签值的匹配模式:

https://github.com/Azure/azure-policy/tree/master/samples/TextPatterns/enforce-tag-match-pattern

关于json - 如何在 Azure 策略中强制实现标签值模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64805977/

相关文章:

azure - 如何检查arm模板中是否存在资源

mongodb - Azure Cosmos DB 检查字段中的数组是否包含在搜索数组中

json - 错误: malformed array literal in PostgreSQL

json - 如何使用golang读取JSON文件中的环境变量?

javascript - 如何过滤Meteor数据库查询结果?

azure - Passport-azure-ad 单点登录 (SSO)

azure - 自动生成 Azure 数据工厂 Assets 的最佳方法

azure - 如何使用 ARM 模板在 Azure Functions 应用程序中禁用 ftps/ftp

azure-devops - 如何将 ResourceID 函数用于应用程序服务槽

java - 从 JSON 数组获取 JSON 数组 Java android