0
0
Azurecloud~5 mins

VM pricing models in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Choosing the right pricing model for virtual machines helps you save money and match your usage needs. Azure offers different ways to pay for VMs depending on how long and how often you use them.
When you want to run a VM for a short test or development and pay only while it runs.
When you plan to run a VM continuously for months and want a lower price by committing upfront.
When you need flexibility to start and stop VMs without long-term commitment.
When you want to save money by reserving VMs for one or three years.
When you want to pay only for the compute time without managing VM infrastructure.
Commands
This command lists available VM sizes and pricing options in the East US region so you can choose the right VM type and pricing model.
Terminal
az vm list-skus --location eastus --output table
Expected OutputExpected
Name Tier Size Family Location Restrictions Standard_B1s Basic Standard_B1s B-series eastus None Standard_D2s_v3 Standard Standard_D2s_v3 D-series eastus None Standard_F4s Standard Standard_F4s F-series eastus None
--location - Specifies the Azure region to list VM SKUs
--output - Formats the output as a readable table
This command creates a new VM with a pay-as-you-go pricing model, which means you pay only for the time the VM runs without upfront commitment.
Terminal
az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --size Standard_B1s --generate-ssh-keys
Expected OutputExpected
{ "fqdns": "", "id": "/subscriptions/xxxx/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM", "location": "eastus", "name": "myVM", "powerState": "VM running", "resourceGroup": "myResourceGroup", "zones": null }
--resource-group - Specifies the resource group to create the VM in
--size - Specifies the VM size which affects pricing
--generate-ssh-keys - Automatically creates SSH keys for secure login
This command creates a one-year reserved instance for the Standard_B1s VM, which lowers the hourly cost by committing to use the VM for one year.
Terminal
az reservations reservation create --name myReservation --sku Standard_B1s --location eastus --quantity 1 --term P1Y
Expected OutputExpected
{ "id": "/subscriptions/xxxx/providers/Microsoft.Capacity/reservationOrders/xxxx/reservations/myReservation", "name": "myReservation", "sku": "Standard_B1s", "term": "P1Y", "location": "eastus", "quantity": 1 }
--sku - Specifies the VM size for the reservation
--term - Specifies the reservation length, e.g., P1Y for one year
--quantity - Number of reserved instances to purchase
This command lists all VMs in the resource group with details including power state and pricing model to verify your VM status and billing type.
Terminal
az vm list --resource-group myResourceGroup --show-details --output table
Expected OutputExpected
Name ResourceGroup Location PowerState VMId myVM myResourceGroup eastus VM running xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
--show-details - Shows extra info like power state
--output - Formats output as a table for easy reading
Key Concept

If you remember nothing else from this pattern, remember: Azure VM pricing models let you choose between paying only for what you use or saving money by committing to longer use.

Common Mistakes
Trying to reserve a VM size that is not available in the chosen region
Reservations only work for VM sizes available in the region, so the command fails or reservation is not applied.
Use 'az vm list-skus' to check available VM sizes in the region before creating a reservation.
Assuming pay-as-you-go VMs stop billing when the VM is deallocated but not deleted
Billing continues for allocated resources like storage even if the VM is stopped but not deallocated.
Stop and deallocate the VM to stop compute charges when not in use.
Summary
Use 'az vm list-skus' to find VM sizes and pricing options in your region.
Create VMs with 'az vm create' to use pay-as-you-go pricing for flexible usage.
Reserve VMs with 'az reservations reservation create' to save money by committing to long-term use.
Check VM status and pricing details with 'az vm list --show-details'.