Search code examples
azureazure-aksazure-cli

How to list all AKS with status via CLI (running/stopped)


I use below statement to list all my aks:

az aks list -o table

This statement seems not to have information about whether the AKS is running or stopped. I see the field "ProvisioningState" which tells me "Succeeded" for a certain cluster, but this cluster is currently stopped. How do I have to extend above statement to get an additional column which tells me whether the corresponding AKS is running or stopped?


Solution

  • You can add required columns with the --query parameter using JMESPath syntax. For example:

    $ az aks list --query "[].{Name:name, Power:powerState.code}" -o table
    Name                    Power
    ----------------------  -------
    cluster-1               Running
    cluster-2               Running