curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az version
az login # opens a browser; use --use-device-code on servers
az account list -o table
az account set --subscription "<name or id>"
Create resources:
az group create --name rg-demo-ci --location centralindia
az vm create --resource-group rg-demo-ci --name vm-demo \
--image Ubuntu2204 --size Standard_B2s \
--admin-username azureuser --generate-ssh-keys
az vm open-port --resource-group rg-demo-ci --name vm-demo --port 80
az vm list -d -o table
Clean up in one command:
az group delete --name rg-demo-ci --yes --no-wait
For automation use a service principal or, better, a managed identity or workload identity federation, rather than your own login:
az ad sp create-for-rbac --name sp-ci --role Contributor \
--scopes /subscriptions/<id>/resourceGroups/rg-demo-ci
Treat the output secret like a password, and scope the role to a resource group, not the whole subscription.