我制定了一项政策来监控资源的命名约定。我们有一个特定的指导方针,提供了一些变化,我想我已经准确地捕捉到了它。
以此为样本
https://docs.microsoft.com/en-us/azure/governance/policy/samples/allow-multiple-name-patterns
我想出了以下我认为可行的方法。问题是当我去部署它时,Azure Policy api 说我定义了参数,但它们没有被使用,而且很明显它们是。寻求有关使用参数创建多名称模式的帮助,如果可能的话。
"properties": {
"displayName": "Match multiple name patterns.",
"description": "Allows one of multiple naming patterns for resources.",
"mode": "Indexed",
"parameters": {
"buName": {
"type": "String",
"metadata": {
"description": "Abbreviated Business Unit / i.e. USNR, SHSD, MAXD"
}
},
"regionShortCode": {
"type": "String",
"metadata": {
"description": "Shortcode for the region / i.e. CUS, NCU, EUS"
}
},
"environmentShortCode": {
"type": "String",
"metadata": {
"description": "Environment code / i.e. D (dev), U (uat), P (prod)"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"not": {
"field": "name",
"match": "[parameters('buName')]-[parameters('regionShortCode')]-[parameters('environmentShortCode')]-???-###"
}
},
{
"not": {
"field": "name",
"match": "[parameters('buName')]-[parameters('regionShortCode')]-[parameters('environmentShortCode')]-???"
}
},
{
"not": {
"field": "name",
"match": "[parameters('regionShortCode')]???[parameters('environmentShortCode')]##"
}
},
{
"not": {
"field": "name",
"match": "[parameters('regionShortCode')]???[parameters('environmentShortCode')]###"
}
}
]
},
"then": {
"effect": "audit"
}
}
}
} ```