VirtualMachineArgs

data class VirtualMachineArgs(val additionalCapabilities: Output<VirtualMachineAdditionalCapabilitiesArgs>? = null, val availabilitySetId: Output<String>? = null, val bootDiagnostics: Output<VirtualMachineBootDiagnosticsArgs>? = null, val deleteDataDisksOnTermination: Output<Boolean>? = null, val deleteOsDiskOnTermination: Output<Boolean>? = null, val identity: Output<VirtualMachineIdentityArgs>? = null, val licenseType: Output<String>? = null, val location: Output<String>? = null, val name: Output<String>? = null, val networkInterfaceIds: Output<List<String>>? = null, val osProfile: Output<VirtualMachineOsProfileArgs>? = null, val osProfileLinuxConfig: Output<VirtualMachineOsProfileLinuxConfigArgs>? = null, val osProfileSecrets: Output<List<VirtualMachineOsProfileSecretArgs>>? = null, val osProfileWindowsConfig: Output<VirtualMachineOsProfileWindowsConfigArgs>? = null, val plan: Output<VirtualMachinePlanArgs>? = null, val primaryNetworkInterfaceId: Output<String>? = null, val proximityPlacementGroupId: Output<String>? = null, val resourceGroupName: Output<String>? = null, val storageDataDisks: Output<List<VirtualMachineStorageDataDiskArgs>>? = null, val storageImageReference: Output<VirtualMachineStorageImageReferenceArgs>? = null, val storageOsDisk: Output<VirtualMachineStorageOsDiskArgs>? = null, val tags: Output<Map<String, String>>? = null, val vmSize: Output<String>? = null, val zones: Output<String>? = null) : ConvertibleToJava<VirtualMachineArgs>

Manages a Virtual Machine.

Disclaimers

Note: The azure.compute.VirtualMachine resource has been superseded by the azure.compute.LinuxVirtualMachine and azure.compute.WindowsVirtualMachine resources. The existing azure.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 the azure.compute.LinuxVirtualMachine and azure.compute.WindowsVirtualMachine resources. Note: Data Disks can be attached either directly on the azure.compute.VirtualMachine resource, or using the azure.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.

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.VirtualNetwork;
import com.pulumi.azure.network.VirtualNetworkArgs;
import com.pulumi.azure.network.Subnet;
import com.pulumi.azure.network.SubnetArgs;
import com.pulumi.azure.network.NetworkInterface;
import com.pulumi.azure.network.NetworkInterfaceArgs;
import com.pulumi.azure.network.inputs.NetworkInterfaceIpConfigurationArgs;
import com.pulumi.azure.compute.VirtualMachine;
import com.pulumi.azure.compute.VirtualMachineArgs;
import com.pulumi.azure.compute.inputs.VirtualMachineStorageImageReferenceArgs;
import com.pulumi.azure.compute.inputs.VirtualMachineStorageOsDiskArgs;
import com.pulumi.azure.compute.inputs.VirtualMachineOsProfileArgs;
import com.pulumi.azure.compute.inputs.VirtualMachineOsProfileLinuxConfigArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var prefix = config.get("prefix").orElse("tfvmex");
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.location("West Europe")
.build());
var mainVirtualNetwork = new VirtualNetwork("mainVirtualNetwork", VirtualNetworkArgs.builder()
.addressSpaces("10.0.0.0/16")
.location(example.location())
.resourceGroupName(example.name())
.build());
var internal = new Subnet("internal", SubnetArgs.builder()
.resourceGroupName(example.name())
.virtualNetworkName(mainVirtualNetwork.name())
.addressPrefixes("10.0.2.0/24")
.build());
var mainNetworkInterface = new NetworkInterface("mainNetworkInterface", NetworkInterfaceArgs.builder()
.location(example.location())
.resourceGroupName(example.name())
.ipConfigurations(NetworkInterfaceIpConfigurationArgs.builder()
.name("testconfiguration1")
.subnetId(internal.id())
.privateIpAddressAllocation("Dynamic")
.build())
.build());
var mainVirtualMachine = new VirtualMachine("mainVirtualMachine", VirtualMachineArgs.builder()
.location(example.location())
.resourceGroupName(example.name())
.networkInterfaceIds(mainNetworkInterface.id())
.vmSize("Standard_DS1_v2")
.storageImageReference(VirtualMachineStorageImageReferenceArgs.builder()
.publisher("Canonical")
.offer("0001-com-ubuntu-server-focal")
.sku("20_04-lts")
.version("latest")
.build())
.storageOsDisk(VirtualMachineStorageOsDiskArgs.builder()
.name("myosdisk1")
.caching("ReadWrite")
.createOption("FromImage")
.managedDiskType("Standard_LRS")
.build())
.osProfile(VirtualMachineOsProfileArgs.builder()
.computerName("hostname")
.adminUsername("testadmin")
.adminPassword("Password1234!")
.build())
.osProfileLinuxConfig(VirtualMachineOsProfileLinuxConfigArgs.builder()
.disablePasswordAuthentication(false)
.build())
.tags(Map.of("environment", "staging"))
.build());
}
}

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

Constructors

Link copied to clipboard
fun VirtualMachineArgs(additionalCapabilities: Output<VirtualMachineAdditionalCapabilitiesArgs>? = null, availabilitySetId: Output<String>? = null, bootDiagnostics: Output<VirtualMachineBootDiagnosticsArgs>? = null, deleteDataDisksOnTermination: Output<Boolean>? = null, deleteOsDiskOnTermination: Output<Boolean>? = null, identity: Output<VirtualMachineIdentityArgs>? = null, licenseType: Output<String>? = null, location: Output<String>? = null, name: Output<String>? = null, networkInterfaceIds: Output<List<String>>? = null, osProfile: Output<VirtualMachineOsProfileArgs>? = null, osProfileLinuxConfig: Output<VirtualMachineOsProfileLinuxConfigArgs>? = null, osProfileSecrets: Output<List<VirtualMachineOsProfileSecretArgs>>? = null, osProfileWindowsConfig: Output<VirtualMachineOsProfileWindowsConfigArgs>? = null, plan: Output<VirtualMachinePlanArgs>? = null, primaryNetworkInterfaceId: Output<String>? = null, proximityPlacementGroupId: Output<String>? = null, resourceGroupName: Output<String>? = null, storageDataDisks: Output<List<VirtualMachineStorageDataDiskArgs>>? = null, storageImageReference: Output<VirtualMachineStorageImageReferenceArgs>? = null, storageOsDisk: Output<VirtualMachineStorageOsDiskArgs>? = null, tags: Output<Map<String, String>>? = null, vmSize: Output<String>? = null, zones: Output<String>? = null)

Functions

Link copied to clipboard
open override fun toJava(): VirtualMachineArgs

Properties

Link copied to clipboard

An additional_capabilities block as defined below.

Link copied to clipboard
val availabilitySetId: Output<String>? = null

The ID of the Availability Set in which the Virtual Machine should exist. Changing this forces a new resource to be created.

Link copied to clipboard

A boot_diagnostics block as defined below.

Link copied to clipboard

Should the Data Disks (either the Managed Disks / VHD Blobs) be deleted when the Virtual Machine is destroyed? Defaults to false.

Link copied to clipboard
val deleteOsDiskOnTermination: Output<Boolean>? = null

Should the OS Disk (either the Managed Disk / VHD Blob) be deleted when the Virtual Machine is destroyed? Defaults to false.

Link copied to clipboard

An identity block as defined below.

Link copied to clipboard
val licenseType: Output<String>? = null

Specifies the BYOL Type for this Virtual Machine. This is only applicable to Windows Virtual Machines. Possible values are Windows_Client and Windows_Server.

Link copied to clipboard
val location: Output<String>? = null

Specifies the Azure Region where the Virtual Machine exists. Changing this forces a new resource to be created.

Link copied to clipboard
val name: Output<String>? = null

Specifies the name of the Virtual Machine. Changing this forces a new resource to be created.

Link copied to clipboard
val networkInterfaceIds: Output<List<String>>? = null

A list of Network Interface IDs which should be associated with the Virtual Machine.

Link copied to clipboard

An os_profile block as defined below. Required when create_option in the storage_os_disk block is set to FromImage.

Link copied to clipboard

(Required, when a Linux machine) An os_profile_linux_config block as defined below.

Link copied to clipboard

One or more os_profile_secrets blocks as defined below.

Link copied to clipboard

(Required, when a Windows machine) An os_profile_windows_config block as defined below.

Link copied to clipboard
val plan: Output<VirtualMachinePlanArgs>? = null

A plan block as defined below.

Link copied to clipboard
val primaryNetworkInterfaceId: Output<String>? = null

The ID of the Network Interface (which must be attached to the Virtual Machine) which should be the Primary Network Interface for this Virtual Machine.

Link copied to clipboard
val proximityPlacementGroupId: Output<String>? = null

The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created

Link copied to clipboard
val resourceGroupName: Output<String>? = null

Specifies the name of the Resource Group in which the Virtual Machine should exist. Changing this forces a new resource to be created.

Link copied to clipboard

One or more storage_data_disk blocks as defined below.

Link copied to clipboard

A storage_image_reference block as defined below. Changing this forces a new resource to be created.

Link copied to clipboard

A storage_os_disk block as defined below.

Link copied to clipboard
val tags: Output<Map<String, String>>? = null

A mapping of tags to assign to the Virtual Machine.

Link copied to clipboard
val vmSize: Output<String>? = null
Link copied to clipboard
val zones: Output<String>? = null

A list of a single item of the Availability Zone which the Virtual Machine should be allocated in. Changing this forces a new resource to be created.