azurerm_ linux_ virtual_ machine cost estimation
A single Linux VM. Billed per hour for the chosen size plus a separate managed OS disk. A Standard_D2s_v5 runs ~$70/month before the disk.
An azurerm_
The compute rate is set entirely by the size. A Standard_
The OS disk is a managed disk billed by tier, not by used bytes. A 128 GB Premium SSD (P10) is a flat ~$19.71/month even if you only write 5 GB to it, because Azure provisions the whole tier. Standard SSD (E-tier) and Standard HDD (S-tier) are cheaper but slower. Picking StandardSSD_
The biggest real-world lever is that compute stops billing when the VM is deallocated (not just powered off from inside the guest), but the disk keeps billing. A fleet of dev VMs auto-deallocated nights and weekends pays compute for ~40% of the hours, while the disks bill the full month.
c3x estimates the compute from the size attribute and the OS disk from os_
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "azurerm_linux_virtual_machine" "app" {
name = "app-vm"
resource_group_name = azurerm_resource_group.main.name
location = "eastus"
size = "Standard_D2s_v5"
admin_username = "azureuser"
network_interface_ids = [azurerm_network_interface.app.id]
admin_ssh_key {
username = "azureuser"
public_key = file("~/.ssh/id_rsa.pub")
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Premium_LRS"
disk_size_gb = 128
}
source_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts-gen2"
version = "latest"
}
}Pricing dimensions
What you actually pay for when you provision azurerm_.
| Dimension | Unit | What's being charged |
|---|---|---|
| Compute (VM size) | per hour | Set by the size attribute. Billed per second while the VM is running; stops when the VM is deallocated. $0.096/hour ≈ $70.08/month for Standard_D2s_v5 (Linux, eastus) |
| OS managed disk | per disk-month | Flat per-tier charge sized to the disk, not bytes used. Bills whether the VM runs or not. $19.71/month for a 128 GB Premium SSD (P10) |
| Data disks (if attached) | per disk-month | Each azurerm_ |
Sample C3X output
A Standard_D2s_v5 with a 128 GB Premium SSD OS disk, running 24/7:
azurerm_linux_virtual_machine.app
├─ Virtual machine (Standard_D2s_v5) 730 hours $70.08
└─ OS disk (Premium SSD P10) 1 disk $19.71
Monthly $89.79Optimization tips
Common ways to reduce azurerm_ cost without changing the workload.
Auto-deallocate non-production VMs off-hours
~60% of compute on non-prodCompute stops billing when a VM is deallocated. An Azure Automation or DevTest Labs schedule that deallocates dev/test VMs nights and weekends cuts compute to ~40% of a 24/7 month. The OS disk still bills, so the saving is on compute only.
Buy a reserved instance or savings plan for steady VMs
40 to 60% on steady computeA 1-year reservation on a VM that genuinely runs 24/7 is ~40% cheaper than pay-as-you-go; 3-year is ~60%. Only commit for baseline capacity you're certain you'll keep running.
Right-size the OS disk tier
~50% on the OS diskA dev box rarely needs Premium SSD. Switching the OS disk from Premium_
Use Spot VMs for interruptible workloads
Up to 90% for interruptible workSpot pricing on a D2s_
FAQ
Does a stopped Azure VM still cost money?
It depends on how it's stopped. 'Stopped' from inside the guest OS (or 'Stopped' state) keeps billing compute because the capacity is still reserved. Only 'Stopped (deallocated)' releases the compute and stops the hourly charge. The OS and data disks bill in both cases.
Why is the same VM size cheaper on Linux than Windows?
Windows VMs include a per-core Windows Server license in the hourly rate; Linux doesn't. For identical hardware the Linux rate is the bare compute. Azure Hybrid Benefit lets you bring your own Windows license to close the gap.
How does c3x price the OS disk?
From os_
Should I use azurerm_ linux_ virtual_ machine or azurerm_ virtual_ machine?
Use azurerm_
Related resources
More Azure resources
Further reading
- Azure Reserved Instances vs Savings Plans: depth vs flexibility
Azure RIs give up to ~72% off a specific VM size; savings plans give up to ~65% across families with full flexibility. Here's which to pick, how they stack with Hybrid Benefit, and why to commit to baseline.
- Azure VM types compared: B vs D vs E vs F series
B-series is burstable. D-series is general. E-series is memory-optimized. F-series is compute-optimized. Family selection drives the bill more than size. Here's the per-vCPU and per-GB pricing math, the decision flow, and the workloads each family wins on.
- How to estimate Azure costs from Terraform
Estimate Azure costs from Terraform configurations including Reserved Instances, Azure Hybrid Benefit, Spot VMs, and Premium SSD tier mapping. Completes the cloud trilogy alongside AWS and GCP.
- Azure Spot VMs: when 90% off is worth the eviction risk
Azure Spot VMs run up to ~90% below pay-as-you-go, evictable with 30 seconds' notice. Here's the eviction model, what workloads fit, AKS Spot pools, and how to design for interruption.
Estimate this resource in your own Terraform
Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including azurerm_.