pulumi_wasm_providers_azure_mini::compute

Module windows_virtual_machine

source
Expand description

Manages a Windows Virtual Machine.

§Disclaimers

Note This provider will automatically remove the OS Disk by default - this behaviour can be configured using the features setting within the Provider block.

Note All arguments including the administrator login and password will be stored in the raw state as plain-text.

Note This resource does not support Unmanaged Disks. If you need to use Unmanaged Disks you can continue to use the azure.compute.VirtualMachine resource instead.

Note This resource does not support attaching existing OS Disks. You can instead capture an image of the OS Disk or continue to use the azure.compute.VirtualMachine resource instead.

In this release there’s a known issue where the public_ip_address and public_ip_addresses fields may not be fully populated for Dynamic Public IP’s.

§Example Usage

This example provisions a basic Windows Virtual Machine on an internal network.

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let example = resource_group::create(
        "example",
        ResourceGroupArgs::builder()
            .location("West Europe")
            .name("example-resources")
            .build_struct(),
    );
    let exampleNetworkInterface = network_interface::create(
        "exampleNetworkInterface",
        NetworkInterfaceArgs::builder()
            .ip_configurations(
                vec![
                    NetworkInterfaceIpConfiguration::builder().name("internal")
                    .privateIpAddressAllocation("Dynamic")
                    .subnetId("${exampleSubnet.id}").build_struct(),
                ],
            )
            .location("${example.location}")
            .name("example-nic")
            .resource_group_name("${example.name}")
            .build_struct(),
    );
    let exampleSubnet = subnet::create(
        "exampleSubnet",
        SubnetArgs::builder()
            .address_prefixes(vec!["10.0.2.0/24",])
            .name("internal")
            .resource_group_name("${example.name}")
            .virtual_network_name("${exampleVirtualNetwork.name}")
            .build_struct(),
    );
    let exampleVirtualNetwork = virtual_network::create(
        "exampleVirtualNetwork",
        VirtualNetworkArgs::builder()
            .address_spaces(vec!["10.0.0.0/16",])
            .location("${example.location}")
            .name("example-network")
            .resource_group_name("${example.name}")
            .build_struct(),
    );
    let exampleWindowsVirtualMachine = windows_virtual_machine::create(
        "exampleWindowsVirtualMachine",
        WindowsVirtualMachineArgs::builder()
            .admin_password("P@$$w0rd1234!")
            .admin_username("adminuser")
            .location("${example.location}")
            .name("example-machine")
            .network_interface_ids(vec!["${exampleNetworkInterface.id}",])
            .os_disk(
                WindowsVirtualMachineOsDisk::builder()
                    .caching("ReadWrite")
                    .storageAccountType("Standard_LRS")
                    .build_struct(),
            )
            .resource_group_name("${example.name}")
            .size("Standard_F2")
            .source_image_reference(
                WindowsVirtualMachineSourceImageReference::builder()
                    .offer("WindowsServer")
                    .publisher("MicrosoftWindowsServer")
                    .sku("2016-Datacenter")
                    .version("latest")
                    .build_struct(),
            )
            .build_struct(),
    );
}

§Import

Windows Virtual Machines can be imported using the resource id, e.g.

$ pulumi import azure:compute/windowsVirtualMachine:WindowsVirtualMachine example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/machine1

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments