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
az vm create \
--resource-group rg-app --name vm-runner \
--image Ubuntu2204 --size Standard_B2s \
--admin-username azureuser --generate-ssh-keys \
--query publicIpAddress -o tsvSubcommands and flags
| Flag | What it does |
|---|---|
| --resource-group, -g | Target resource group |
| --name, -n | VM name |
| --image | OS image alias or URN, e.g. Ubuntu2204 |
| --size | VM SKU, e.g. Standard_B2s |
| --admin-username | Initial admin account |
| --generate-ssh-keys | Create 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.