azure Commands

Configuration

az login

Log in to Azure.

az login

Examples:
Log in interactively
az login
Log in with a service principal
az login --service-principal -u <app-id> -p <password-or-cert> --tenant <tenant>
az account set

Set a subscription to be the current active subscription.

az account set

Examples:
Set the active subscription
az account set --subscription 'My Subscription Name'

Resource Group

az group list

List resource groups.

az group list

Examples:
List all resource groups
az group list
List resource groups and format as a table
az group list -o table
az group create

Create a new resource group.

az group create

Examples:
Create a new resource group in the West US region
az group create --name MyResourceGroup --location westus

Virtual Machine

az vm list

Get the details of the virtual machines.

az vm list

Examples:
List all VMs in the default subscription
az vm list
List VMs in a specific resource group and show details
az vm list --resource-group MyResourceGroup --show-details -o table
az vm create

Create an Azure Virtual Machine.

az vm create

Examples:
Create a default Ubuntu VM
az vm create -n MyVm -g MyResourceGroup --image UbuntuLTS --generate-ssh-keys
Create a Windows Server 2019 VM
az vm create -n MyWinVm -g MyResourceGroup --image Win2019Datacenter --admin-username myadmin --admin-password 'MyComplexPassword123!'
az vm start

Start a stopped virtual machine.

az vm start

Examples:
Start a VM
az vm start --resource-group MyResourceGroup --name MyVm
az vm stop

Stop a running virtual machine.

az vm stop

Examples:
Stop a VM
az vm stop --resource-group MyResourceGroup --name MyVm

Storage

az storage account list

List storage accounts.

az storage account list

Examples:
List all storage accounts in the subscription
az storage account list
az storage blob list

List blobs in a given container.

az storage blob list

Examples:
List blobs in a container
az storage blob list --account-name mystorageaccount --container-name mycontainer -o table

Active Directory

az ad user list

List users in Azure Active Directory.

az ad user list

Examples:
List all users in the tenant
az ad user list

Deployment

az deployment group create

Start a deployment.

az deployment group create

Examples:
Deploy an ARM template from a local file
az deployment group create --resource-group MyResourceGroup --template-file mytemplate.json --parameters myparam=myvalue