VirtualMachine
A resource of the Azure provider, version 0.3.0, in its Compute group. Import it with:
import VirtualMachine from "azure/compute"Example
resource VirtualMachine example {
name = "example-value"
resourceGroup = "example-value"
location = "example-value"
size = "example-value"
adminUsername = "example-value"
adminPassword = "example-value"
sshPublicKey = "example-value"
imagePublisher = "example-value"
imageOffer = "example-value"
imageSku = "example-value"
imageVersion = "latest"
subnetId = "example-value"
publicIpAddressId = "example-value"
networkSecurityGroupId = "example-value"
osDiskSizeGb = 3.14
osDiskType = "Premium_LRS"
osDiskCaching = "ReadWrite"
computerName = "example-value"
customData = "example-value"
zones = "..."
tags = "..."
}Properties
Set by your code in the resource block. A required one must be set; any other you leave out takes the value under Default, if it has one.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | string | — | No | The name of the virtual machine |
resourceGroup | string | — | No | The Azure resource group name |
location | string | — | No | The Azure region/location |
size | string | — | No | The VM size (e.g., Standard_B2s, Standard_D2s_v3) |
adminUsername | string | — | No | The admin username for the VM |
adminPassword | string | — | No | The admin password (for Windows or password auth) |
sshPublicKey | string | — | No | The SSH public key for Linux VMs |
imagePublisher | string | — | No | The image publisher (e.g., Canonical, MicrosoftWindowsServer) |
imageOffer | string | — | No | The image offer (e.g., 0001-com-ubuntu-server-jammy, WindowsServer) |
imageSku | string | — | No | The image SKU (e.g., 22_04-lts-gen2, 2022-datacenter-azure-edition) |
imageVersion | string | "latest" | No | The image version |
subnetId | string | — | No | The subnet ID to attach the VM to |
publicIpAddressId | string | — | No | The public IP address ID to associate |
networkSecurityGroupId | string | — | No | The network security group ID for the NIC |
osDiskSizeGb | number | — | No | The OS disk size in GB |
osDiskType | string | "Premium_LRS" | No | The OS disk type Allowed: "Standard_LRS", "StandardSSD_LRS", "Premium_LRS", "UltraSSD_LRS" |
osDiskCaching | string | "ReadWrite" | No | The OS disk caching Allowed: "None", "ReadOnly", "ReadWrite" |
computerName | string | — | No | The computer name (hostname). Defaults to VM name |
customData | string | — | No | Custom data for cloud-init (Linux) or CustomScriptExtension (Windows) |
zones | any[] | — | No | Availability zones for the VM |
tags | object | — | No | Tags to apply to the VM and its resources |
Set by Azure after the resource is created: your code can read them but not set them. An importable one identifies an existing resource.
| Name | Type | Importable | Description |
|---|---|---|---|
id | string | Yes | The Azure resource ID of the VM |
vmId | string | No | The VM unique ID |
provisioningState | string | No | The provisioning state |
powerState | string | No | The power state (running, deallocated, etc.) |
privateIp | string | No | The private IP address |
publicIp | string | No | The public IP address (if assigned) |
networkInterfaceId | string | No | The network interface ID |
osDiskName | string | No | The OS disk name |