AzureAzure Virtual MachinesCompute

azurerm_linux_virtual_machine cost estimation

A Linux VM on Azure. Priced per hour by VM size, region, and license. Managed disks and bandwidth billed separately.

An azurerm_linux_virtual_machine provisions one Linux VM in Azure. Cost has three main parts.

First, the per-hour rate for the VM size. Azure VM sizes are organized into families (Bs, Dsv5, Esv5, Fsv2, etc.), each with different CPU/memory ratios and price points. The Bs (burstable) family is cheapest and right for low-baseline workloads; Dsv5 is the general-purpose default; Esv5 has more memory per vCPU; Fsv2 has higher CPU-to-memory ratios for compute-heavy work.

Second, managed disks. The OS disk and any data disks are billed per GB-month, with rates depending on the disk type (Standard HDD, Standard SSD, Premium SSD, Ultra SSD). Premium SSD is the default for production. Disk billing continues when the VM is stopped (deallocated does not stop disk billing).

Third, outbound bandwidth. Data transferred out of the Azure region incurs egress charges. The first 100 GB/month is free at the subscription level; beyond that, it is usage-based.

c3x reads the VM size, OS disk type, and data disk attachments from the Terraform configuration. Bandwidth requires a c3x-usage.yml entry to model accurately.

Terraform example

A minimal but realistic configuration that C3X can estimate.

resource "azurerm_linux_virtual_machine" "api" {
  name                = "api-vm"
  resource_group_name = azurerm_resource_group.main.name
  location            = "eastus"
  size                = "Standard_D2s_v5"
  admin_username      = "azureuser"

  network_interface_ids = [azurerm_network_interface.api.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         = 64
  }

  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_linux_virtual_machine.

DimensionUnitWhat's being charged
VM hoursper hourOn-demand rate for the VM size in the chosen region. c3x assumes 730 hours per month.
$0.096/hour for Standard_D2s_v5 in eastus
OS diskper GB-monthProvisioned size of the os_disk. Premium SSDs are billed by a tiered per-disk price, not raw GB-month.
$5.28/month for P10 (128 GB Premium SSD)
Data disksper GB-month or per-disk tierSame pricing model as the OS disk. Premium and Ultra SSDs use a tiered per-disk model.
Outbound bandwidthper GBEgress from the Azure region. First 100 GB/month free at the subscription level. Define expected volume in c3x-usage.yml.

Optimization tips

Common ways to reduce azurerm_linux_virtual_machine cost without changing the workload.

Use B-series for low-baseline workloads

Up to 55%

B-series (Bs) VMs use a CPU credit model that costs much less than always-on D-series at the same advertised vCPU count. Right for workloads that burst occasionally.

Reserve VMs for steady-state workloads

30-50%

Azure Reserved VM Instances cut on-demand prices by 30-50% in exchange for a 1-year or 3-year commitment. Set purchaseOption: 'reserved' in c3x-usage.yml to model this.

Consider Standard SSD instead of Premium for non-prod

About 50% on disks

Premium SSD is the default for production but Standard SSD is roughly half the cost. For dev/staging where IOPS aren't critical, downgrade the os_disk type.

FAQ

Does c3x estimate Windows VMs?

Yes, via azurerm_windows_virtual_machine. Windows pricing includes a per-vCPU license surcharge that can double the hourly rate. c3x picks up the OS automatically.

How does Azure Hybrid Benefit affect the estimate?

Azure Hybrid Benefit (bring-your-own Windows or RHEL license) cuts the per-hour rate significantly. Set license_type = 'Windows_Server' on the resource and c3x will apply the AHB discount.

Why is the Premium SSD price not a flat GB-month rate?

Azure Premium SSDs are billed by tier (P1 through P80), with each tier giving fixed IOPS and throughput at a fixed monthly price. Pricing is not proportional to provisioned size below a tier boundary.

Related resources

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_linux_virtual_machine.