Azure CLI (az)
Logging in and subscriptions, resource groups, VMs, AKS, storage and Key Vault.
Auth and subscriptions
Log in
az loginLog in without a browser (servers)
az login --use-device-codeList subscriptions
az account list --output tableSwitch subscription
az account set --subscription <az_subscription>
Resources
Resource groups
az group list --output tableResources in a group
az resource list --resource-group <az_resource_group> --output table
Delete a resource group with everything in itadvanced
az group delete --name <az_resource_group> --yes --no-wait
Virtual machines
VMs with power state and IPs
az vm list --show-details --output tableStart or deallocate a VM (stops billing for compute)
az vm deallocate --resource-group <az_resource_group> --name <azure_vm>
Run a shell command on a VMadvanced
az vm run-command invoke --resource-group <az_resource_group> --name <azure_vm> --command-id RunShellScript --scripts "uptime"
AKS, storage, Key Vault
kubectl credentials for an AKS cluster
az aks get-credentials --resource-group <az_resource_group> --name <aks_cluster>
List blobs in a container
az storage blob list --account-name <az_storage_account> --container-name <az_container> --auth-mode login --output table
Upload a directory to blob storage
az storage blob upload-batch --account-name <az_storage_account> --destination <az_container> --source ./dist --auth-mode login
Read a Key Vault secret
az keyvault secret show --vault-name <az_key_vault> --name <az_secret> --query value --output tsv
Filter output with JMESPathadvanced
az vm list --query "[?location=='westeurope'].name" --output tsv