Azure CLI 2 cheatsheet

Azure CLI 2: Containers, Kubernetes and secrets

7 common Azure CLI 2 tasks.

Sign Docker in to a registry

Authenticate Docker to Azure Container Registry.

az acr login --name myregistry

Build an image in the registry

Build and push an image in Azure with no local Docker needed.

az acr build --registry myregistry --image myapp:v1 .

Connect kubectl to AKS

Merge the cluster's credentials into your kubeconfig.

az aks get-credentials --resource-group my-rg --name my-cluster

Scale an AKS node pool

Change the number of nodes in a cluster.

az aks scale --resource-group my-rg --name my-cluster --node-count 3

Read a Key Vault secret

Print one secret's value.

az keyvault secret show --vault-name my-vault --name db-password --query value --output tsv

Caution: This prints the secret in your terminal.

Store a Key Vault secret

Create or update a secret. Use a real value.

az keyvault secret set --vault-name my-vault --name db-password --value "change-me"

Deploy a Bicep template

Deploy infrastructure defined in a Bicep file to a resource group.

az deployment group create --resource-group my-rg --template-file main.bicep

Was this page helpful?