How to Fix Azure policy that blocks VM Deployment when Lisence option is selected On Basics page?

Sello Ledwala 0 Reputation points
2023-03-31T12:30:06.45+00:00

I have created a policy to allow certain version OF Windows server OS version when creating VM on azure portal .

What happens is that i have list of allowed OS on the Policy anything that not on the list policy blocks the deployment..

When i select "Would you like to use an existing Windows Server license?" on the basics page after creating Admin credentials it fails the validation even though i have selected allowed version.

But if i dont tick or ignore " Would you like to use an existing Windows Server license?" the validation passwed the policy doesnt block deployment


    },
    "parameters": {},
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "in": [
              "Microsoft.Compute/virtualMachines",
              "Microsoft.Compute/VirtualMachineScaleSets"
            ]
          },
          {
            "allOf": [
              {
                "not": {
                  "allOf": [
                    {
                      "field": "Microsoft.Compute/licenseType",
                      "notEquals": "Windows_Server"
                    },
                    {
                      "field": "Microsoft.Compute/imagePublisher",
                      "in": [
                        "MicrosoftWindowsServer"
                      ]
                    },
                    {
                      "field": "Microsoft.Compute/imageOffer",
                      "in": [
                        "WindowsServer"
                      ]
                    },
                    {
                      "field": "Microsoft.Compute/imageSku",
                      "in": [
                        "2019-Datacenter",
                        "2019-datacenter-gensecond",
                        "2019-Datacenter-core",
                        "2019-Datacenter-core-g2",
                        "2019-Datacenter-Core-smalldisk"
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
803 questions
{count} votes