0
0
Azurecloud~5 mins

Azure Reserved Instances - Commands & Configuration

Choose your learning style9 modes available
Introduction
Azure Reserved Instances let you save money by paying upfront for virtual machines you plan to use for a long time. This helps reduce costs compared to paying as you go.
When you know you will run a virtual machine continuously for one or three years.
When you want to lower your cloud costs for steady workloads like databases or web servers.
When you want to plan your cloud budget with predictable monthly costs.
When you want to reserve capacity in a specific Azure region to ensure availability.
When you want to combine reserved instances with pay-as-you-go for flexible scaling.
Commands
List all your virtual machines with their names, resource groups, locations, and sizes to decide which VM size to reserve.
Terminal
az vm list --query "[].{Name:name, ResourceGroup:resourceGroup, Location:location, Size:hardwareProfile.vmSize}" -o table
Expected OutputExpected
Name ResourceGroup Location Size myVM1 myResourceGroup eastus Standard_DS1_v2 myVM2 myResourceGroup eastus Standard_DS2_v2
--query - Filters and formats the output to show only needed fields.
-o table - Displays output in a readable table format.
Purchase a reserved instance for one Standard_DS1_v2 virtual machine in the East US region for one year to save costs.
Terminal
az reservations reservation-order create --reserved-resource-type VirtualMachines --sku Standard_DS1_v2 --term P1Y --quantity 1 --location eastus
Expected OutputExpected
{ "id": "/providers/Microsoft.Capacity/reservationOrders/12345678-1234-1234-1234-123456789abc", "name": "12345678-1234-1234-1234-123456789abc", "properties": { "provisioningState": "Succeeded", "term": "P1Y", "quantity": 1, "reservedResourceType": "VirtualMachines", "sku": "Standard_DS1_v2", "location": "eastus" }, "type": "Microsoft.Capacity/reservationOrders" }
--reserved-resource-type - Specifies the type of resource to reserve, here virtual machines.
--sku - Specifies the VM size to reserve.
--term - Specifies the reservation duration, here one year (P1Y).
--quantity - Number of reserved instances to purchase.
--location - Azure region where the reserved instance applies.
List all your active reservation orders to verify your reserved instances.
Terminal
az reservations reservation-order list
Expected OutputExpected
[ { "id": "/providers/Microsoft.Capacity/reservationOrders/12345678-1234-1234-1234-123456789abc", "name": "12345678-1234-1234-1234-123456789abc", "properties": { "provisioningState": "Succeeded", "term": "P1Y", "quantity": 1, "reservedResourceType": "VirtualMachines", "sku": "Standard_DS1_v2", "location": "eastus" }, "type": "Microsoft.Capacity/reservationOrders" } ]
Key Concept

If you remember nothing else from this pattern, remember: buying reserved instances saves money by committing to use specific virtual machines for a set time.

Common Mistakes
Trying to reserve a VM size that does not match your running VM.
The reserved instance discount only applies if the VM size and region match exactly.
Check your VM size and region carefully before purchasing a reserved instance.
Buying reserved instances without knowing the term commitment.
You pay upfront for one or three years, so canceling early is not possible and can waste money.
Plan your usage duration before buying reserved instances.
Summary
List your current virtual machines to identify which VM size and region to reserve.
Purchase a reserved instance using the Azure CLI with the correct VM size, region, and term.
Verify your reserved instances by listing your reservation orders.