Expand description
Manages a Virtual Machine.
§Disclaimers
Note: The
azure.compute.VirtualMachine
resource has been superseded by theazure.compute.LinuxVirtualMachine
andazure.compute.WindowsVirtualMachine
resources. The existingazure.compute.VirtualMachine
resource will continue to be available throughout the 2.x releases however is in a feature-frozen state to maintain compatibility - new functionality will instead be added to theazure.compute.LinuxVirtualMachine
andazure.compute.WindowsVirtualMachine
resources.
Note: Data Disks can be attached either directly on the
azure.compute.VirtualMachine
resource, or using theazure.compute.DataDiskAttachment
resource - but the two cannot be used together. If both are used against the same Virtual Machine, spurious changes will occur.
§Example Usage
§From An Azure Platform Image)
This example provisions a Virtual Machine with Managed Disks.
configuration:
prefix:
type: string
default: tfvmex
resources:
example:
type: azure:core:ResourceGroup
properties:
name: ${prefix}-resources
location: West Europe
main:
type: azure:network:VirtualNetwork
properties:
name: ${prefix}-network
addressSpaces:
- 10.0.0.0/16
location: ${example.location}
resourceGroupName: ${example.name}
internal:
type: azure:network:Subnet
properties:
name: internal
resourceGroupName: ${example.name}
virtualNetworkName: ${main.name}
addressPrefixes:
- 10.0.2.0/24
mainNetworkInterface:
type: azure:network:NetworkInterface
name: main
properties:
name: ${prefix}-nic
location: ${example.location}
resourceGroupName: ${example.name}
ipConfigurations:
- name: testconfiguration1
subnetId: ${internal.id}
privateIpAddressAllocation: Dynamic
mainVirtualMachine:
type: azure:compute:VirtualMachine
name: main
properties:
name: ${prefix}-vm
location: ${example.location}
resourceGroupName: ${example.name}
networkInterfaceIds:
- ${mainNetworkInterface.id}
vmSize: Standard_DS1_v2
storageImageReference:
publisher: Canonical
offer: 0001-com-ubuntu-server-jammy
sku: 22_04-lts
version: latest
storageOsDisk:
name: myosdisk1
caching: ReadWrite
createOption: FromImage
managedDiskType: Standard_LRS
osProfile:
computerName: hostname
adminUsername: testadmin
adminPassword: Password1234!
osProfileLinuxConfig:
disablePasswordAuthentication: false
tags:
environment: staging
§Import
Virtual Machines can be imported using the resource id
, e.g.
$ pulumi import azure:compute/virtualMachine:VirtualMachine example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/machine1
Structs§
- Use builder syntax to set the inputs and finish with
build_struct()
.
Functions§
- Registers a new resource with the given unique name and arguments