Install the Azure CLI and sign in
Bash
# Ubuntu / Debian
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# macOS
brew install azure-cli
# Check version
az --version
# Sign in
az login # Browser authentication
az login --use-device-code # Device-code authentication (servers)
# Select a subscription
az account list --output table
az account set --subscription "Subscription name or ID"
# Current context
az account showCreate a resource group
Every Azure resource belongs to a resource group.
Bash
# Create a resource group
az group create --name my-rg --location koreacentral # Korea Central
# List locations
az account list-locations --output table | grep korea
# List resource groups
az group list --output table
# Delete a resource group (deletes all resources inside — use with caution)
az group delete --name my-rg --yes --no-waitCreate a virtual machine
Bash
# Create an Ubuntu VM
az vm create --resource-group my-rg --name my-vm --image Ubuntu2204 --size Standard_B2s --admin-username azureuser --generate-ssh-keys --location koreacentral
# Create a Windows VM
az vm create --resource-group my-rg --name my-win-vm --image Win2022Datacenter --size Standard_B2s --admin-username azureuser --admin-password "MyP@ssw0rd123"
# List VMs
az vm list --output table
az vm list -g my-rg --output table
# Start / stop / restart a VM
az vm start --resource-group my-rg --name my-vm
az vm stop --resource-group my-rg --name my-vm
az vm restart --resource-group my-rg --name my-vm
# SSH access (get the public IP)
az vm show -g my-rg -n my-vm -d --query publicIps -o tsvNetwork security groups (NSG)
Bash
# Create an NSG
az network nsg create --resource-group my-rg --name my-nsg
# Add inbound rules
az network nsg rule create --resource-group my-rg --nsg-name my-nsg --name allow-ssh --protocol tcp --direction inbound --priority 100 --source-address-prefix '*' --destination-port-range 22 --access allow
az network nsg rule create --resource-group my-rg --nsg-name my-nsg --name allow-http --protocol tcp --direction inbound --priority 110 --source-address-prefix '*' --destination-port-range 80 --access allow
# Associate the NSG with a NIC
az network nic update --resource-group my-rg --name my-vmVMNic --network-security-group my-nsgVirtual network (VNet)
Bash
# Create a VNet
az network vnet create --resource-group my-rg --name my-vnet --address-prefix 10.0.0.0/16 --location koreacentral
# Add subnets
az network vnet subnet create --resource-group my-rg --vnet-name my-vnet --name public-subnet --address-prefix 10.0.1.0/24
az network vnet subnet create --resource-group my-rg --vnet-name my-vnet --name private-subnet --address-prefix 10.0.2.0/24Azure Blob Storage
Bash
# Create a storage account
az storage account create --name mystorageaccount1234 --resource-group my-rg --location koreacentral --sku Standard_LRS --kind StorageV2
# Create a container (bucket)
az storage container create --name mycontainer --account-name mystorageaccount1234 --public-access off
# Upload a file
az storage blob upload --account-name mystorageaccount1234 --container-name mycontainer --file ./myfile.txt --name myfile.txt
# List files
az storage blob list --account-name mystorageaccount1234 --container-name mycontainer --output table
# Download a file
az storage blob download --account-name mystorageaccount1234 --container-name mycontainer --name myfile.txt --file ./downloaded.txtCost-saving tips
- B-series VMs: Inexpensive burstable instances for development
- Reserved instances: Up to 72% off with a 1- or 3-year commitment
- Spot instances: Up to 90% off; can be evicted at any time
- Deallocate unused VMs — stopping them alone still incurs compute charges
Bash
az vm deallocate --resource-group my-rg --name my-vmEditorial note
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Topic-related official docs (auto-linked · not per-claim sources)Microsoft Azure documentation ↗pgvector repository ↗
Questions & answers
Ask a question about this guide. We'll review and reply.