Created
March 21, 2024 16:51
-
-
Save caseywatson/81e575e0f3745065e2a5ac59dd59e23d to your computer and use it in GitHub Desktop.
Groups VMs based on VM name using the beginning letters to the first digit to determine if vmGroup is spread across two or more availability zones. For output, it includes the tag, Application Name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resources | |
| | where type =~ 'microsoft.compute/virtualmachines' | |
| | project vmId = id, vmName = name, vmZone = tostring(zones[0]), vmGroup = trim_end('\\d+$', name), appName = tags['Application Name'], location | |
| | summarize vmCount = count(), zoneCount = dcountif(vmZone, isnotempty(vmZone)) by vmGroup | |
| | where zoneCount < min_of(vmCount, 2) | |
| | join kind=inner( | |
| resources | |
| | where type=~ 'microsoft.compute/virtualmachines' | |
| | project vmId = id, vmName = name, vmZone = tostring(zones[0]), vmGroup = trim_end('\\d+$', name), appName = tags['Application Name'], location) on vmGroup | |
| | project vmGroup, vmName, location, vmZone, vmId, appName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment