Tip: KQL Query for Azure VMs with Periodic Assessment Enabled


Unfortunately due to personal reasons I haven’t been able to blog for a while. I am hoping I can change that and this will be one of those small blog posts. Recently on Microsoft Q&A there was question if you can get all Azure VMs with Period Assessment (Azure Update Manager feature) enabled.

This can be achieved easily by using Azure Resource Graph and Kusto Query Language (KQL) query.

resources
| where type =~ "microsoft.compute/virtualmachines" 
| where properties.storageProfile.osDisk.osType in~ ('Linux','Windows')
| extend patchSettingsObject = iff(properties.storageProfile.osDisk.osType =~ "windows", properties.osProfile.windowsConfiguration.patchSettings, properties.osProfile.linuxConfiguration.patchSettings)
| extend assessMode = tostring(patchSettingsObject.assessmentMode)
| extend periodicAssessment = iff(isnotnull(assessMode) and assessMode =~ "AutomaticByPlatform", "Yes", "No")

The result with Yes or No you can see in periodicAssessment column. I hope you will find this useful.

One thought on “Tip: KQL Query for Azure VMs with Periodic Assessment Enabled

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.