The Microsoft Azure CLI 2.0 seems to be continously under development.

Compared to the Web-GUI it delivers faster results and information in my view.

One thing I am using it for, is to get an overview about all the Linux related hosts on one subscription.

az vm list --show-details \
  --query "[?storageProfile.osDisk.osType=='Linux'].{VMName:name, Power:powerState, RG:resourceGroup, State:provisioningState}" \
  -o table'

For the convenience, I assigned this to an alias:

alias az.vm.os.linux="az vm list --show-details \
  --query \"[?storageProfile.osDisk.osType=='Linux'].{VMName:name, Power:powerState, RG:resourceGroup, State:provisioningState}\" \
  -o table"

This query lists all the Linux type hosts in Microsoft Azure and the state they are in:

VMName                 Power       RG                          State
---------------------  ----------  --------------------------  ---------
host01                 VM running  HOST-RG-01                  Succeeded
host02                 VM running  HOST-RG-01                  Succeeded
host03                 VM running  HOST-RG-02                  Succeeded
host04                 VM running  HOST-RG-02                  Succeeded

Using this method and the parameter –query, the most common information can be gathered quite quickly from Microsoft Azure and are available a Linux host as well.

After writing this, I have already updated this command to include the reported distribution and version as well (if available).

alias az.vm.os.linux='az vm list \
  --show-details \
  --query "[?storageProfile.osDisk.osType=='\''Linux'\''].{VMName:name, \
    Power:powerState, \
    RG:resourceGroup, \
    OS:storageProfile.imageReference.offer, \
    Version:storageProfile.imageReference.sku, \
    State:provisioningState}" \
  -o table'