Hi namedk-4467,
In Azure Policy, the parameters
field does not support arrays for tag names. The policy rule checks each field individually, so it’s not possible to pass an array of tag names directly into the field
property of the policy rule.
However, you can achieve similar functionality by creating a separate policy for each tag you want to check. You can then group these policies into an initiative. Here’s an example of how you can do this:
{
"mode": "Indexed",
"policyRule": {
"if": {
"field": "[concat('tags[', parameters('tagName'), ']')]",
"exists": "false"
},
"then": {
"effect": "audit"
}
},
"parameters": {
"tagName": {
"type": "String",
"metadata": {
"displayName": "Tag Name",
"description": "Name of the tag to check"
}
}
}
}
In this example, you would create a separate policy for each tag (environment
, location
, costCenter
, etc.) and replace the tagName
parameter with the actual tag name. Then, group these policies into an initiative.
This way, you can check for the existence of multiple tags without having to specify each tag as a separate parameter in the policy rule. However, it does require more setup as you need to create a policy for each tag.
References:
If the information helped address your question, please Accept the answer.
Luis