Hi Garg,Srishti,
This query should now properly join the VM resources with their associated maintenance configurations based on their subscription IDs and scope.
resources
| where type == "microsoft.compute/virtualmachines"
| extend subscriptionId = tolower(tostring(split(id, '/')[2])) // Extract subscription ID once
| extend tags = todynamic(tags) // Parse tags as dynamic object
| project vmName = name, vmId = id, resourceGroup, location, subscriptionId, tags
| join kind=inner (
resources
| where type == "microsoft.maintenance/configurationassignments"
| extend assignedSubscription = tolower(tostring(split(id, '/')[2])) // Extract subscription ID once
| mv-expand properties = todynamic(properties) // Expand properties to access scopes
| project maintenanceConfigId = id, assignedSubscription, configname = name, scope = tostring(properties.scope)
) on subscriptionId == assignedSubscription and id == scope
| project vmName, vmId, resourceGroup, location, maintenanceConfigId, configname, tags
Please refer blow Documentation for your refence
https://learn.microsoft.com/en-us/azure/update-manager/updates-maintenance-schedules
https://learn.microsoft.com/en-us/azure/virtual-machines/maintenance-configurations
https://learn.microsoft.com/en-us/azure/virtual-machines/resource-graph-samples?tabs=azure-cli
If the information is helpful, please consider by clicking the "Upvote" on the post.
If you have any further queries, please let us know in the comment.
Thank you.