I'm struggling with a custom policy. My requirements are the following:
Enable Hybrid Use Benefit for Microsoft.Compute/virtualMachines (properties.licenseType=Windows_Server)
Work for both Marketplace and not-Marketplace virtual machines (ASRed, etc)
Fix deployments that are done without it enabled
Allow remediation of existing resources
Initially I found Community Policy - deploy-hybrid-benefit-windows which works for Marketplace, but not for VMs without imagePublisher and imageOffer. I identified properties.storageProfile.osDisk.osType as another way to identify Windows machines.
The full policy if below, but it only works for remediation, it does not work for new deployments. What am I doing wrong?