> For the complete documentation index, see [llms.txt](https://docs.mechcloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mechcloud.io/cloud-computing/stateless-iac/azure/examples-resources-with-cost/microsoft.compute/instance-virtual-machine.md).

# Instance (Virtual Machine)

{% hint style="info" %}
**Updated**: February 13, 2026
{% endhint %}

{% hint style="info" %}
These examples assume that linked resources (VNet, Subnet, NIC) already exist in the same resource group.
{% endhint %}

## Creating a virtual machine with Standard SSD

```yaml
defaults:
  resource_group: rg1

resources:
  - type: "Microsoft.Compute/virtualMachines"
    api_version: "2025-04-01"
    name: vm1
    props:
      hardware_profile:
        vm_size: Standard_B2pts_v2
      os_profile:
        computer_name: testvm
        admin_username: ubuntu
        admin_password: SecureP@ss2024!
      network_profile:
        network_interfaces:
          - id: "/providers/Microsoft.Network/networkInterfaces/nic1"
      storage_profile:
        image_reference:
          publisher: Canonical
          offer: ubuntu-24_04-lts
          sku: server-arm64
          version: latest
        os_disk:
          create_option: FromImage
          delete_option: Delete
          managed_disk:
            storage_account_type: StandardSSD_LRS
          disk_size_gb: 60
```

### Example plan output

```
vm1 (action: create, monthly: $10.93, change: +100%)
  => Compute (price: $0.0084/Hr, monthly: $6.13, spot-price: $0.00756/Hr, spot-monthly: $5.52)
  => OS Disk (monthly: $4.80)
    => E6 LRS Disk Operations (price: $0.002/10K)
    => E6 LRS Disk (price: $4.8/Month, size: 64, monthly: $4.80)
```

## Creating a virtual machine with Premium SSD

```yaml
defaults:
  resource_group: rg1
  
resources:
  - type: "Microsoft.Compute/virtualMachines"
    api_version: "2025-04-01"
    name: vm1
    props:
      hardware_profile:
        vm_size: Standard_B2pts_v2
      os_profile:
        computer_name: testvm
        admin_username: ubuntu
        admin_password: SecureP@ss2024!
      network_profile:
        network_interfaces:
          - id: "/providers/Microsoft.Network/networkInterfaces/nic1"
      storage_profile:
        image_reference:
          publisher: Canonical
          offer: ubuntu-24_04-lts
          sku: server-arm64
          version: latest
        os_disk:
          create_option: FromImage
          delete_option: Delete
          managed_disk:
            storage_account_type: Premium_ZRS
          disk_size_gb: 60
```

### Example plan output

```
vm1 (action: create, monthly: $20.05, change: +100%)
  => Compute (price: $0.0084/Hr, monthly: $6.13, spot-price: $0.00756/Hr, spot-monthly: $5.52)
  => OS Disk (monthly: $13.92)
    => P6 ZRS Disk (price: $13.92/Month, size: 64, monthly: $13.92)
```

## Creating a virtual machine with Premium SSD v2

```yaml
defaults:
  resource_group: rg1
  
resources:
  - type: "Microsoft.Compute/virtualMachines"
    api_version: "2025-04-01"
    name: vm1
    props:
      hardware_profile:
        vm_size: Standard_B2pts_v2
      os_profile:
        computer_name: testvm
        admin_username: ubuntu
        admin_password: SecureP@ss2024!
      network_profile:
        network_interfaces:
          - id: "/providers/Microsoft.Network/networkInterfaces/nic1"
      storage_profile:
        image_reference:
          publisher: Canonical
          offer: ubuntu-24_04-lts
          sku: server-arm64
          version: latest
        os_disk:
          create_option: FromImage
          delete_option: Delete
          managed_disk:
            storage_account_type: PremiumV2_LRS
          disk_size_gb: 40
          disk_iops_read_write: 5000
          disk_mbps_read_write: 150
```

### Example plan output

```
vm1 (action: create, monthly: $20.57, change: +100%)
  => Compute (price: $0.0084/Hr, monthly: $6.13, spot-price: $0.00756/Hr, spot-monthly: $5.52)
  => OS Disk (monthly: $14.44)
    => Storage cost (price: $0.00011/GiB/Hr, size: 40, monthly: $3.21)
    => IOPS (monthly: $10.22)
      => Tier 1 (First 3000 IOPS included - quantity: 3000, monthly: $0.00)
      => Tier 2 (Over 3000 IOPS - price: $0.000007/GiB/Hr, quantity: 2000, monthly: $10.22)
    => Throughput (monthly: $1.00)
      => Tier 1 (First 125 MB/s included - quantity: 125, monthly: $0.00)
      => Tier 2 (Over 125 MB/s - price: $0.000055/GiB/Hr, quantity: 25, monthly: $1.00)
```
