Create a policy to disable NICs that don't have a certain tag to be able to attach certain IPs

Mirko Krajcer 0 Reputation points
2025-04-29T18:24:30.4166667+00:00

I want to disable NICs that don't have a tag

my:tag:name

being equal to

123456

to assign PRIVATE IPs from a predefined list

[1.2.3.4, 5.6.7.8, 9.10.11.12, ...]

using a policy or any other Microsoft service. Can you help me?

I've tried doing this and it is not working:

{
  "mode": "Indexed",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Network/networkInterfaces"
        },
        {
          "field": "tags['my:tag:name']",
          "equals": "123456"
        },
        {
          "field": "Microsoft.Network/networkInterfaces/ipConfigurations[*].privateIPAddress",
          "in": [
            "1.2.3.4",
            "5.6.7.8",
            "9.10.11.12"
          ]
        }
      ]
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {}
}
Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
752 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.