azure-policy
azure-policy copied to clipboard
VirtualMachineBackup_Backup_DeployIfNotExists: Doesn't detect MicrosoftSQLServer on WS2022
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
VirtualMachineBackup_Backup_DeployIfNotExists
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/VirtualMachineBackup_Backup_DeployIfNotExists.json#L190-L220
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"
}
]
}
]
}