Home > Net >  How can I check the state of over 200 VM's in Azure?
How can I check the state of over 200 VM's in Azure?

Time:09-17

To display the state (Running, Deallocated etc) of our VM's, I currently use the following command and this works fine.

az vm list -o table -d -g ....

With the number of VM's increasing on a regular basis, this is getting very cumbersome. For 200 VM's, I need to run this command 200 times.

Is there an easier way to obtain this information, by querying GraphAPI maybe ?

CodePudding user response:

I have reproduced in my environment and Thanks to @volody, followed his SO-thread and below is the query to run in Azure Resource Graph explorer:

      Resources
        | project name, location,
        PowerState=tostring(properties.extended.instanceView.powerState.code),
type
        | where type =~ 'Microsoft.Compute/virtualMachines'
        | order  by name desc ```

enter image description here

References taken from:

Edit 2:

Yes you can get different vms using names as below: I used has :

| where name has "x" or name has "y"

enter image description here

  • Related