我想对资源组所需的标签强制执行标签值模式“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/