Hi,
I guess it depends on how do you test in order to define that is not working. This policy will work only if all of the defined tags do not have the defined tag values. Keep in mind that this policy will also not care if you do not have the tag defined at all.
My suggestion is to create one policy definition and do 5 policy assignments for each definition with different input - one policy assignment for each tag and value pair.
Example policy rule
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"anyOf": [
{
"allOf": [
{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "false"
},
{
"value": "[resourceGroup().tags[parameters('tagName')]]",
"notEquals": "[parameters('tagValue')]"
}
]
},
{
"allOf": [
{
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "true"
},
{
"value": "[resourceGroup().tags[parameters('tagName')]]",
"notEquals": "[parameters('tagValue')]"
}
]
}
]
}
]
},
"then": {
"effect": "modify",
"details": {
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"operations": [
{
"operation": "addOrReplace",
"field": "[concat('tags[', parameters('tagName'), ']')]",
"value": "[parameters('tagValue')]"
}
]
}
}
}
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.