Azure CLI
Install Azure CLI
Azure CLI Commands
Azure login
Get available Azure cloud
az cloud list -o table
Switch to Azure China cloud
az cloud set --name AzureChinaCloud
Login to Azure
az login
# To see if logged in
az account list
az account show
az account get-access-token
Get available Azure cloud locations:
az account list-locations -o table
# Get name only
az account list-locations --query "[].{Name:name}" -o table
# Get more details
az account list-locations --query "[].{Name:name, DisplayName:displayName, PhysicalLocation:metadata.physicalLocation}" -o table
Azure resource info
Get available Azure resource groups:
az group list -o table
# Get available Azure resource groups in a specific location:
az group list --query "[?location=='chinanorth3']" -o table
Get available Azure SKUs:
az vm list-skus -o table
# Get specific SKUs in a specific location
az vm list-skus --resource-type virtualMachines -l chinanorth3 -o table
az postgres flexible-server list-skus -l chinanorth3 -o table
az mysql flexible-server list-skus -l chinanorth3 -o table
Azure resource operations
VM operations
# Get VM list
az vm list -o table
# Get VM details
az vm list -d -o table
Get Azure Redis Cache:
az redis list
# Get hostname only
az redis list --query "[].{HostName:hostName}" -o table
# Get more details
az redis list --query "[].{HostName:hostName, Port:port, SslPort:sslPort, Version:redisVersion}" -o table
Get Azure PostgreSQL Flexible Server:
az postgres flexible-server list
# Get fully qualified domain name
az postgres flexible-server list --query "[].{FQDN:fullyQualifiedDomainName}" -o table
Get Azure Kubernetes Service (AKS):
az aks list -o table