Skip to main content
Providers

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.

NameTypeDefaultRequiredDescription
namestring—NoThe name of the virtual machine
resourceGroupstring—NoThe Azure resource group name
locationstring—NoThe Azure region/location
sizestring—NoThe VM size (e.g., Standard_B2s, Standard_D2s_v3)
adminUsernamestring—NoThe admin username for the VM
adminPasswordstring—NoThe admin password (for Windows or password auth)
sshPublicKeystring—NoThe SSH public key for Linux VMs
imagePublisherstring—NoThe image publisher (e.g., Canonical, MicrosoftWindowsServer)
imageOfferstring—NoThe image offer (e.g., 0001-com-ubuntu-server-jammy, WindowsServer)
imageSkustring—NoThe image SKU (e.g., 22_04-lts-gen2, 2022-datacenter-azure-edition)
imageVersionstring"latest"NoThe image version
subnetIdstring—NoThe subnet ID to attach the VM to
publicIpAddressIdstring—NoThe public IP address ID to associate
networkSecurityGroupIdstring—NoThe network security group ID for the NIC
osDiskSizeGbnumber—NoThe OS disk size in GB
osDiskTypestring"Premium_LRS"NoThe OS disk type Allowed: "Standard_LRS", "StandardSSD_LRS", "Premium_LRS", "UltraSSD_LRS"
osDiskCachingstring"ReadWrite"NoThe OS disk caching Allowed: "None", "ReadOnly", "ReadWrite"
computerNamestring—NoThe computer name (hostname). Defaults to VM name
customDatastring—NoCustom data for cloud-init (Linux) or CustomScriptExtension (Windows)
zonesany[]—NoAvailability zones for the VM
tagsobject—NoTags 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.

NameTypeImportableDescription
idstringYesThe Azure resource ID of the VM
vmIdstringNoThe VM unique ID
provisioningStatestringNoThe provisioning state
powerStatestringNoThe power state (running, deallocated, etc.)
privateIpstringNoThe private IP address
publicIpstringNoThe public IP address (if assigned)
networkInterfaceIdstringNoThe network interface ID
osDiskNamestringNoThe OS disk name

On this page