Skip to content
Latchkey

az vm create: Provision a Virtual Machine

az vm create provisions a virtual machine with the image, size, and networking you specify.

Ephemeral VMs back load tests and self-hosted runners. vm create spins one up, and the JSON it returns carries the IP you need for the next step.

What it does

az vm create provisions a VM in a resource group, creating a NIC, OS disk, and (by default) a public IP. It returns a JSON object with publicIpAddress and other details once the machine is running.

Common usage

Terminal
az vm create \
  --resource-group rg-app --name vm-runner \
  --image Ubuntu2204 --size Standard_B2s \
  --admin-username azureuser --generate-ssh-keys \
  --query publicIpAddress -o tsv

Subcommands and flags

FlagWhat it does
--resource-group, -gTarget resource group
--name, -nVM name
--imageOS image alias or URN, e.g. Ubuntu2204
--sizeVM SKU, e.g. Standard_B2s
--admin-usernameInitial admin account
--generate-ssh-keysCreate SSH keys if absent
--public-ip-address ""Omit a public IP (private-only VM)

In CI

Capture the address with --query publicIpAddress -o tsv to feed an SSH or smoke-test step. For private runners pass --public-ip-address "" and reach the VM over the VNet. Tag throwaway VMs so a cleanup job can find them.

Common errors in CI

"QuotaExceeded ... exceeding approved Total Regional Cores quota" means the region is at its core limit; choose a smaller size or another region. "InvalidParameter: The value of parameter adminUsername is not allowed" rejects names like admin or root. "AuthorizationFailed" on the write action means the identity lacks Contributor.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →