Hello,
I am trying to create a policy that will only allow certain values in a specific tag name.
https://learn.microsoft.com/en-us/azure/governance/policy/concepts/definition-structure#value-count-examples
According to the examples and the description of "current", then it should evaluate each array value and see if they match the where clause.
E.g. Environment = DEV
Environment = STG
Environment = PRD.
This behavior seem to not be true though?!

This is a picture of the non-compliance for a resource group that SHOULD BE compliant, since the tag is Environment = DEV.
I tried to put the Count.value = DEV and that one is working, but as soon as there are more values in the array, it is not working. It is showing compliance only for the incorrect tags.
Furthermore, I have tried to use match, like, and notmatch instead of equals. Also not after where. I also tried to parameterized the array with no difference.
{
"mode": "All",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"count": {
"value": [
"DEV",
"STG",
"PRD"
],
"where": {
"field": "[concat('tags[', parameters('envTagName'), ']')]",
"equals": "[current()]"
}
},
"greaterOrEquals": 1
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the audit policy"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
},
"envTagName": {
"type": "String",
"metadata": {
"displayName": "Environment Tag Name",
"description": "Name of the tag, such as 'environment'"
},
"defaultValue": "Environment"
}
}
}