> 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)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mechcloud.io/cloud-computing/stateless-iac/azure/examples-resources-with-cost/microsoft.compute/instance-virtual-machine.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
