import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const config = new pulumi.Config(); * const prefix = config.get("prefix") || "tfvmex"; * const example = new azure.core.ResourceGroup("example", { * name: `${prefix}-resources`, * location: "West Europe", * }); * const main = new azure.network.VirtualNetwork("main", { * name: `${prefix}-network`, * addressSpaces: ["10.0.0.0/16"], * location: example.location, * resourceGroupName: example.name, * }); * const internal = new azure.network.Subnet("internal", { * name: "internal", * resourceGroupName: example.name, * virtualNetworkName: main.name, * addressPrefixes: ["10.0.2.0/24"], * }); * const mainNetworkInterface = new azure.network.NetworkInterface("main", { * name: `${prefix}-nic`, * location: example.location, * resourceGroupName: example.name, * ipConfigurations: [{ * name: "testconfiguration1", * subnetId: internal.id, * privateIpAddressAllocation: "Dynamic", * }], * }); * const mainVirtualMachine = new azure.compute.VirtualMachine("main", { * 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", * }, * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Compute` - 2024-03-01, 2023-04-02 * * * `Microsoft.Network` - 2025-01-01 * * ## Import * * Virtual Machines can be imported using the `resource id`, e.g. * * ```sh * $ pulumi import azure:compute/virtualMachine:VirtualMachine example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/machine1 * ``` */ export declare class VirtualMachine extends pulumi.CustomResource { /** * Get an existing VirtualMachine resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: VirtualMachineState, opts?: pulumi.CustomResourceOptions): VirtualMachine; /** * Returns true if the given object is an instance of VirtualMachine. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is VirtualMachine; /** * An `additionalCapabilities` block as defined below. */ readonly additionalCapabilities: pulumi.Output; /** * The ID of the Availability Set in which the Virtual Machine should exist. Changing this forces a new resource to be created. */ readonly availabilitySetId: pulumi.Output; /** * A `bootDiagnostics` block as defined below. */ readonly bootDiagnostics: pulumi.Output; /** * Should the Data Disks (either the Managed Disks / VHD Blobs) be deleted when the Virtual Machine is destroyed? Defaults to `false`. * * > **Note:** This setting works when instance is deleted via the provider only and don't forget to delete disks manually if you deleted VM manually. It can increase spending. */ readonly deleteDataDisksOnTermination: pulumi.Output; /** * Should the OS Disk (either the Managed Disk / VHD Blob) be deleted when the Virtual Machine is destroyed? Defaults to `false`. * * > **Note:** This setting works when instance is deleted via the provider only and don't forget to delete disks manually if you deleted VM manually. It can increase spending. */ readonly deleteOsDiskOnTermination: pulumi.Output; /** * An `identity` block as defined below. */ readonly identity: pulumi.Output; /** * Specifies the BYOL Type for this Virtual Machine. This is only applicable to Windows Virtual Machines. Possible values are `Windows_Client` and `Windows_Server`. */ readonly licenseType: pulumi.Output; /** * Specifies the Azure Region where the Virtual Machine exists. Changing this forces a new resource to be created. */ readonly location: pulumi.Output; /** * Specifies the name of the Virtual Machine. Changing this forces a new resource to be created. */ readonly name: pulumi.Output; /** * A list of Network Interface IDs which should be associated with the Virtual Machine. */ readonly networkInterfaceIds: pulumi.Output; /** * An `osProfile` block as defined below. Required when `createOption` in the `storageOsDisk` block is set to `FromImage`. */ readonly osProfile: pulumi.Output; /** * (Required, when a Linux machine) An `osProfileLinuxConfig` block as defined below. */ readonly osProfileLinuxConfig: pulumi.Output; /** * One or more `osProfileSecrets` blocks as defined below. */ readonly osProfileSecrets: pulumi.Output; /** * (Required, when a Windows machine) An `osProfileWindowsConfig` block as defined below. */ readonly osProfileWindowsConfig: pulumi.Output; /** * A `plan` block as defined below. */ readonly plan: pulumi.Output; /** * 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. */ readonly primaryNetworkInterfaceId: pulumi.Output; /** * The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created */ readonly proximityPlacementGroupId: pulumi.Output; /** * Specifies the name of the Resource Group in which the Virtual Machine should exist. Changing this forces a new resource to be created. */ readonly resourceGroupName: pulumi.Output; /** * One or more `storageDataDisk` blocks as defined below. * * > **Please Note:** Data Disks can also be attached either using this block or the `azure.compute.DataDiskAttachment` resource - but not both. */ readonly storageDataDisks: pulumi.Output; /** * A `storageImageReference` block as defined below. Changing this forces a new resource to be created. */ readonly storageImageReference: pulumi.Output; /** * A `storageOsDisk` block as defined below. */ readonly storageOsDisk: pulumi.Output; /** * A mapping of tags to assign to the Virtual Machine. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Specifies the [size of the Virtual Machine](https://docs.microsoft.com/azure/virtual-machines/sizes-general). See also [Azure VM Naming Conventions](https://docs.microsoft.com/azure/virtual-machines/vm-naming-conventions). */ readonly vmSize: pulumi.Output; /** * 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. * * > **Please Note:** Availability Zones are [only supported in several regions at this time](https://docs.microsoft.com/azure/availability-zones/az-overview). * * For more information on the different example configurations, please check out the [Azure documentation](https://docs.microsoft.com/en-gb/rest/api/compute/virtualmachines/createorupdate#examples) */ readonly zones: pulumi.Output; /** * Create a VirtualMachine resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: VirtualMachineArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering VirtualMachine resources. */ export interface VirtualMachineState { /** * An `additionalCapabilities` block as defined below. */ additionalCapabilities?: pulumi.Input; /** * The ID of the Availability Set in which the Virtual Machine should exist. Changing this forces a new resource to be created. */ availabilitySetId?: pulumi.Input; /** * A `bootDiagnostics` block as defined below. */ bootDiagnostics?: pulumi.Input; /** * Should the Data Disks (either the Managed Disks / VHD Blobs) be deleted when the Virtual Machine is destroyed? Defaults to `false`. * * > **Note:** This setting works when instance is deleted via the provider only and don't forget to delete disks manually if you deleted VM manually. It can increase spending. */ deleteDataDisksOnTermination?: pulumi.Input; /** * Should the OS Disk (either the Managed Disk / VHD Blob) be deleted when the Virtual Machine is destroyed? Defaults to `false`. * * > **Note:** This setting works when instance is deleted via the provider only and don't forget to delete disks manually if you deleted VM manually. It can increase spending. */ deleteOsDiskOnTermination?: pulumi.Input; /** * An `identity` block as defined below. */ identity?: pulumi.Input; /** * Specifies the BYOL Type for this Virtual Machine. This is only applicable to Windows Virtual Machines. Possible values are `Windows_Client` and `Windows_Server`. */ licenseType?: pulumi.Input; /** * Specifies the Azure Region where the Virtual Machine exists. Changing this forces a new resource to be created. */ location?: pulumi.Input; /** * Specifies the name of the Virtual Machine. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * A list of Network Interface IDs which should be associated with the Virtual Machine. */ networkInterfaceIds?: pulumi.Input[]>; /** * An `osProfile` block as defined below. Required when `createOption` in the `storageOsDisk` block is set to `FromImage`. */ osProfile?: pulumi.Input; /** * (Required, when a Linux machine) An `osProfileLinuxConfig` block as defined below. */ osProfileLinuxConfig?: pulumi.Input; /** * One or more `osProfileSecrets` blocks as defined below. */ osProfileSecrets?: pulumi.Input[]>; /** * (Required, when a Windows machine) An `osProfileWindowsConfig` block as defined below. */ osProfileWindowsConfig?: pulumi.Input; /** * A `plan` block as defined below. */ plan?: pulumi.Input; /** * 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. */ primaryNetworkInterfaceId?: pulumi.Input; /** * The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created */ proximityPlacementGroupId?: pulumi.Input; /** * Specifies the name of the Resource Group in which the Virtual Machine should exist. Changing this forces a new resource to be created. */ resourceGroupName?: pulumi.Input; /** * One or more `storageDataDisk` blocks as defined below. * * > **Please Note:** Data Disks can also be attached either using this block or the `azure.compute.DataDiskAttachment` resource - but not both. */ storageDataDisks?: pulumi.Input[]>; /** * A `storageImageReference` block as defined below. Changing this forces a new resource to be created. */ storageImageReference?: pulumi.Input; /** * A `storageOsDisk` block as defined below. */ storageOsDisk?: pulumi.Input; /** * A mapping of tags to assign to the Virtual Machine. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Specifies the [size of the Virtual Machine](https://docs.microsoft.com/azure/virtual-machines/sizes-general). See also [Azure VM Naming Conventions](https://docs.microsoft.com/azure/virtual-machines/vm-naming-conventions). */ vmSize?: pulumi.Input; /** * 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. * * > **Please Note:** Availability Zones are [only supported in several regions at this time](https://docs.microsoft.com/azure/availability-zones/az-overview). * * For more information on the different example configurations, please check out the [Azure documentation](https://docs.microsoft.com/en-gb/rest/api/compute/virtualmachines/createorupdate#examples) */ zones?: pulumi.Input; } /** * The set of arguments for constructing a VirtualMachine resource. */ export interface VirtualMachineArgs { /** * An `additionalCapabilities` block as defined below. */ additionalCapabilities?: pulumi.Input; /** * The ID of the Availability Set in which the Virtual Machine should exist. Changing this forces a new resource to be created. */ availabilitySetId?: pulumi.Input; /** * A `bootDiagnostics` block as defined below. */ bootDiagnostics?: pulumi.Input; /** * Should the Data Disks (either the Managed Disks / VHD Blobs) be deleted when the Virtual Machine is destroyed? Defaults to `false`. * * > **Note:** This setting works when instance is deleted via the provider only and don't forget to delete disks manually if you deleted VM manually. It can increase spending. */ deleteDataDisksOnTermination?: pulumi.Input; /** * Should the OS Disk (either the Managed Disk / VHD Blob) be deleted when the Virtual Machine is destroyed? Defaults to `false`. * * > **Note:** This setting works when instance is deleted via the provider only and don't forget to delete disks manually if you deleted VM manually. It can increase spending. */ deleteOsDiskOnTermination?: pulumi.Input; /** * An `identity` block as defined below. */ identity?: pulumi.Input; /** * Specifies the BYOL Type for this Virtual Machine. This is only applicable to Windows Virtual Machines. Possible values are `Windows_Client` and `Windows_Server`. */ licenseType?: pulumi.Input; /** * Specifies the Azure Region where the Virtual Machine exists. Changing this forces a new resource to be created. */ location?: pulumi.Input; /** * Specifies the name of the Virtual Machine. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * A list of Network Interface IDs which should be associated with the Virtual Machine. */ networkInterfaceIds: pulumi.Input[]>; /** * An `osProfile` block as defined below. Required when `createOption` in the `storageOsDisk` block is set to `FromImage`. */ osProfile?: pulumi.Input; /** * (Required, when a Linux machine) An `osProfileLinuxConfig` block as defined below. */ osProfileLinuxConfig?: pulumi.Input; /** * One or more `osProfileSecrets` blocks as defined below. */ osProfileSecrets?: pulumi.Input[]>; /** * (Required, when a Windows machine) An `osProfileWindowsConfig` block as defined below. */ osProfileWindowsConfig?: pulumi.Input; /** * A `plan` block as defined below. */ plan?: pulumi.Input; /** * 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. */ primaryNetworkInterfaceId?: pulumi.Input; /** * The ID of the Proximity Placement Group to which this Virtual Machine should be assigned. Changing this forces a new resource to be created */ proximityPlacementGroupId?: pulumi.Input; /** * Specifies the name of the Resource Group in which the Virtual Machine should exist. Changing this forces a new resource to be created. */ resourceGroupName: pulumi.Input; /** * One or more `storageDataDisk` blocks as defined below. * * > **Please Note:** Data Disks can also be attached either using this block or the `azure.compute.DataDiskAttachment` resource - but not both. */ storageDataDisks?: pulumi.Input[]>; /** * A `storageImageReference` block as defined below. Changing this forces a new resource to be created. */ storageImageReference?: pulumi.Input; /** * A `storageOsDisk` block as defined below. */ storageOsDisk: pulumi.Input; /** * A mapping of tags to assign to the Virtual Machine. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Specifies the [size of the Virtual Machine](https://docs.microsoft.com/azure/virtual-machines/sizes-general). See also [Azure VM Naming Conventions](https://docs.microsoft.com/azure/virtual-machines/vm-naming-conventions). */ vmSize: pulumi.Input; /** * 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. * * > **Please Note:** Availability Zones are [only supported in several regions at this time](https://docs.microsoft.com/azure/availability-zones/az-overview). * * For more information on the different example configurations, please check out the [Azure documentation](https://docs.microsoft.com/en-gb/rest/api/compute/virtualmachines/createorupdate#examples) */ zones?: pulumi.Input; }