azure-policy icon indicating copy to clipboard operation
azure-policy copied to clipboard

VirtualMachineWithTag_Backup_Deploy: Doesn't detect MicrosoftSQLServer on WS2022

Open haflidif opened this issue 1 year ago • 0 comments

Details of the scenario you tried and the problem that is occurring

When deploying a VM with ImagePublisher: MicrosoftSQLServer and with ImageOffer WS2022 the built-in policy VirtualMachineWithTag_Backup_Deploy doesn't detect that type of VM as that image offer is missing from the policy definition.

Verbose logs showing the problem

https://github.com/Azure/azure-policy/blob/4d0406f3652d39cd026b29298f165df5c4ce59f7/built-in-policies/policyDefinitions/Backup/VirtualMachineWithTag_Backup_Deploy.json#L175-L205

Suggested solution to the issue

{
  "allOf": [
    {
      "field": "Microsoft.Compute/imagePublisher",
      "equals": "MicrosoftSQLServer"
    },
    {
      "anyOf": [
       { 
          "field": "Microsoft.Compute/imageOffer",
          "like": "*-WS2022"
        },
        {
          "field": "Microsoft.Compute/imageOffer",
          "like": "*-WS2019"
        },
        {
          "field": "Microsoft.Compute/imageOffer",
          "like": "*-WS2016"
        },
        {
          "field": "Microsoft.Compute/imageOffer",
          "like": "*-WS2016-BYOL"
        },
        {
          "field": "Microsoft.Compute/imageOffer",
          "like": "*-WS2012R2"
        },
        {
          "field": "Microsoft.Compute/imageOffer",
          "like": "*-WS2012R2-BYOL"
        }
      ]
    }
  ]
}

If policy is Guest Configuration - details about target node

This is as well connected to issue #1197

haflidif avatar Aug 11 '23 07:08 haflidif