Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy does not remediate automatically on deployment of Windows VM #454

Merged
merged 5 commits into from
Jun 26, 2024

Conversation

jeircul
Copy link
Contributor

@jeircul jeircul commented Jun 6, 2024

Policy will not work when deploying a new VM, because of the "if" condition.

{
  "field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
  "equals": "Windows"
}

Explanation

The issue is that the create payload for VMs does not include the property osType, which is evaluated in the "if" condition the Policy, which makes Policy see the resource as not applicable for a deployment until later.

Solution

The solution is to check on the image reference, and this PR shows 1 way of doing exactly that.

Other relevant info

The policy works fine "as is" for manually remediating and will also be triggered by any change to the VM (for example a resize).

@jeircul jeircul changed the title Change 'osType' to 'imageOffer' Policy does not remediate automatically on deployment of Windows VM Jun 6, 2024
jeircul added 2 commits June 10, 2024 10:56
Added back check for osType. 
Also included checks for common imagePublisher values.
@jeircul
Copy link
Contributor Author

jeircul commented Jun 10, 2024

@microsoft-github-policy-service agree

Added microsoftwindowsdesktop
@DFRZ7 DFRZ7 merged commit 4614c37 into Azure:main Jun 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants