how to check if tags dont exists

Daniel Saada | CloudTeam.ai 21 Reputation points
2022-05-02T10:17:42.4+00:00

hi everyone,

im trying to check if the inserted tags do not exists on the resource using a policy(policy to prevent somthing, unless it has the tags).
the tags are insert into an array parameter in the following format: Key;Value, Key;Value

this is the code i have:

 {
     "count": {
         "value": "[parameters('ExcludeTags')]",
         "name": "tag",
         "where": {
             "field": "[format('tags[{0}]',split(current('tag'),';')[0])]",
             "equals": "[split(current('tag'),';')[1]]"
          }
      },
      "equals": 0
},

but i get the following error when im deploying the policy:

The policy definition 'the policy id' rule is invalid. The 'field' property value '[format('tags[{0}]',split(current('tag'),';')[0])]' is invalid. 'field' and 'current' functions are not supported in the 'field' accessor.

does somebody know how to fix this?

thank you

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
829 questions
{count} votes