Azure Compute Windows Virtual Machine

This page shows how to write Terraform and Azure Resource Manager for Compute Windows Virtual Machine and write them securely.

azurerm_windows_virtual_machine (Terraform)

The Windows Virtual Machine in Compute can be configured in Terraform with the resource name azurerm_windows_virtual_machine. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

VM.tf#L51
resource "azurerm_windows_virtual_machine" "VM1" {
  name = "VM1"
  resource_group_name = var.ResourceGroup
  location = var.location
  size = local.size
  admin_username = "adminuser"
compute.tf#L18
resource "azurerm_windows_virtual_machine" "web-vm" {
  name                = "web-tier-vm"
  resource_group_name = var.rg-name
  location            = var.rg-location
  size                = "Standard_F2"
  admin_username      = "adminuser"
main.tf#L74
resource "azurerm_windows_virtual_machine" "vm0" {
  depends_on = [azurerm_network_interface.nicvm0]
  name                = "vm-vnet0"
  location            = var.location
  resource_group_name = var.rg_name
  size                = "Standard_F2"
virtualmachine.tf#L3
    resource "azurerm_windows_virtual_machine" "VM1356" {
    name                = var.VM1356name
    resource_group_name = azurerm_resource_group.TESTlab.name
    location            = azurerm_resource_group.TESTlab.location
    size                = var.VM1356size
    admin_username      = var.VM1356adminusername
virtual_machines.tf#L1
resource "azurerm_windows_virtual_machine" "iis_1" {
  name                = "iis-machine-1"
  resource_group_name = azurerm_resource_group.iis_rg.name
  location            = azurerm_resource_group.iis_rg.location
  size                = "Standard_F2"
  admin_username      = var.admin_username
vm_infra.tf#L42
resource "azurerm_windows_virtual_machine" "macrolife" {
  name                = "example-machine"
  resource_group_name = var.resource_group_name
  location            = locals.location
  size                = "Standard_F2"
  subnet              = "subnetVnetmacrolife001_1"
Question2.tf#L88
resource "azurerm_windows_virtual_machine" "example" {
  name                  = "myvm1"
  location              = "eastus"
  resource_group_name   = azurerm_resource_group.easrrg.name
  network_interface_ids = [azurerm_network_interface.eastmyvm1nic.id]
  size                  = "Standard_B1s"
azureresource.tf#L42
resource "azurerm_windows_virtual_machine" "ausevm" {
  name                = "auedemo-vm01"
  resource_group_name = azurerm_resource_group.rg.name
  location            = "australiaeast"
  size                = "Standard_ds2_v2"
  admin_username      = "kloudadmin"
main.tf#L1
resource "azurerm_windows_virtual_machine" "vm_windows" {

    name                    =   var.instance_name
    resource_group_name     =   var.resource_group_name
    location                =   var.location
    size                    =   var.size
main.tf#L13
resource "azurerm_windows_virtual_machine" "example" {
  name                = "vm-web-fe-01"
  resource_group_name = var.resource_group_name
  location            = var.location
  size                = "Standard_F2"
  admin_username      = "adminuser"

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Windows Virtual Machine.

Tips: Best Practices for The Other Azure Compute Resources

In addition to the azurerm_linux_virtual_machine, Azure Compute has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.

risk-label

azurerm_linux_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

risk-label

azurerm_managed_disk

Ensure to enable the encryption on managed disks

It is better to enable the encryption on managed disks.

risk-label

azurerm_virtual_machine

Ensure to use SSH authentication for virtual machines

It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.

Review your Azure Compute settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

Microsoft.Compute/virtualMachines (Azure Resource Manager)

The virtualMachines in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/virtualMachines. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

app.json#L25
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('SharedVmConfig').location]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('SharedVmConfig').vmSize]"
app.json#L29
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('SharedVmConfig').location]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('SharedVmConfig').vmSize]"
client.json#L40
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('SharedVmConfig').location]",
      "dependsOn": [
        "[variables('ImageName')]"
      ],
addc.json#L25
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('SharedVmConfig').location]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('SharedVmConfig').vmSize]"
client.json#L23
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('SharedVmConfig').location]",
      "dependsOn": [],
      "properties": {
        "hardwareProfile": {
addc.json#L30
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('SharedVmConfig').location]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('SharedVmConfig').vmSize]"
vmPatchMgmt.json#L45
            "type": "Microsoft.Compute/virtualMachines",
            "name": "[parameters('vmName')]",
            "apiVersion": "2017-03-30",
            "location": "[parameters('vmLocation')]",
            "identity": {
                "type": "SystemAssigned"
DSCLab_Full.json#L255
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "2016-04-30-preview",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "Microsoft.Network/networkInterfaces/dc1nic1"
            ],
vm.json#L16
            "type": "Microsoft.Compute/virtualMachines",
            "apiVersion": "[parameters('computeSettings').computeApiVersion]",
            "location": "[parameters('computeSettings').location]",

            "properties": {
                "osProfile": {
runScripts.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "vmName": {

Parameters

  • apiVersion required - string
  • extendedLocation optional
      • name optional - string

        The name of the extended location.

      • type optional - string

        The type of the extended location.

  • identity optional
      • type optional - string

        The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine.

      • userAssignedIdentities optional - undefined

        The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.

  • location required - string

    Resource location

  • name required - string

    The name of the virtual machine.

  • plan optional
      • name optional - string

        The plan ID.

      • product optional - string

        Specifies the product of the image from the marketplace. This is the same value as Offer under the imageReference element.

      • promotionCode optional - string

        The promotion code.

      • publisher optional - string

        The publisher ID.

  • properties required
      • additionalCapabilities optional
          • hibernationEnabled optional - boolean

            The flag that enables or disables hibernation capability on the VM.

          • ultraSSDEnabled optional - boolean

            The flag that enables or disables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale set only if this property is enabled.

      • applicationProfile optional
          • galleryApplications optional array
              • configurationReference optional - string

                Optional, Specifies the uri to an azure blob that will replace the default configuration for the package if provided

              • order optional - integer

                Optional, Specifies the order in which the packages have to be installed

              • packageReferenceId required - string

                Specifies the GalleryApplicationVersion resource id on the form of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version}

              • tags optional - string

                Optional, Specifies a passthrough value for more generic context.

      • availabilitySet optional
          • id optional - string

            Resource Id

      • billingProfile optional
          • maxPrice optional - number

            Specifies the maximum price you are willing to pay for a Azure Spot VM/VMSS. This price is in US Dollars. This price will be compared with the current Azure Spot price for the VM size. Also, the prices are compared at the time of create/update of Azure Spot VM/VMSS and the operation will only succeed if the maxPrice is greater than the current Azure Spot price. The maxPrice will also be used for evicting a Azure Spot VM/VMSS if the current Azure Spot price goes beyond the maxPrice after creation of VM/VMSS. Possible values are: - Any decimal value greater than zero. Example: 0.01538 -1 – indicates default price to be up-to on-demand. You can set the maxPrice to -1 to indicate that the Azure Spot VM/VMSS should not be evicted for price reasons. Also, the default max price is -1 if it is not provided by you. Minimum api-version: 2019-03-01.

      • capacityReservation optional
          • capacityReservationGroup optional
              • id optional - string

                Resource Id

      • diagnosticsProfile optional
          • bootDiagnostics optional
              • enabled optional - boolean

                Whether boot diagnostics should be enabled on the Virtual Machine.

              • storageUri optional - string

                Uri of the storage account to use for placing the console output and screenshot. If storageUri is not specified while enabling boot diagnostics, managed storage will be used.

      • evictionPolicy optional - string

        Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview.

      • extensionsTimeBudget optional - string

        Specifies the time alloted for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. The default value is 90 minutes (PT1H30M). Minimum api-version: 2020-06-01

      • hardwareProfile optional
      • host optional
          • id optional - string

            Resource Id

      • hostGroup optional
          • id optional - string

            Resource Id

      • licenseType optional - string

        Specifies that the image or disk that is being used was licensed on-premises. Possible values for Windows Server operating system are: Windows_Client Windows_Server Possible values for Linux Server operating system are: RHEL_BYOS (for RHEL) SLES_BYOS (for SUSE) For more information, see Azure Hybrid Use Benefit for Windows Server Azure Hybrid Use Benefit for Linux Server Minimum api-version: 2015-06-15

      • networkProfile optional
          • networkApiVersion optional - string

            specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations.

          • networkInterfaceConfigurations optional array
              • name required - string

                The network interface configuration name.

              • properties optional
                  • deleteOption optional - string

                    Specify what happens to the network interface when the VM is deleted.

                  • dnsSettings optional
                      • dnsServers optional - array

                        List of DNS servers IP addresses

                  • dscpConfiguration optional
                      • id optional - string

                        Resource Id

                  • enableAcceleratedNetworking optional - boolean

                    Specifies whether the network interface is accelerated networking-enabled.

                  • enableFpga optional - boolean

                    Specifies whether the network interface is FPGA networking-enabled.

                  • enableIPForwarding optional - boolean

                    Whether IP forwarding enabled on this NIC.

                  • ipConfigurations required array
                      • name required - string

                        The IP configuration name.

                      • properties optional
                          • applicationGatewayBackendAddressPools optional array
                              • id optional - string

                                Resource Id

                          • applicationSecurityGroups optional array
                              • id optional - string

                                Resource Id

                          • loadBalancerBackendAddressPools optional array
                              • id optional - string

                                Resource Id

                          • primary optional - boolean

                            Specifies the primary network interface in case the virtual machine has more than 1 network interface.

                          • privateIPAddressVersion optional - string

                            Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'.

                          • publicIPAddressConfiguration optional
                              • name required - string

                                The publicIP address configuration name.

                              • properties optional
                                  • deleteOption optional - string

                                    Specify what happens to the public IP address when the VM is deleted.

                                  • dnsSettings optional
                                      • domainNameLabel required - string

                                        The Domain name label prefix of the PublicIPAddress resources that will be created. The generated name label is the concatenation of the domain name label and vm network profile unique ID.

                                  • idleTimeoutInMinutes optional - integer

                                    The idle timeout of the public IP address.

                                  • ipTags optional array
                                      • ipTagType optional - string

                                        IP tag type. Example: FirstPartyUsage.

                                      • tag optional - string

                                        IP tag associated with the public IP. Example: SQL, Storage etc.

                                  • publicIPAddressVersion optional - string

                                    Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'.

                                  • publicIPAllocationMethod optional - string

                                    Specify the public IP allocation type.

                                  • publicIPPrefix optional
                                      • id optional - string

                                        Resource Id

                              • sku optional
                                  • name optional - string

                                    Specify public IP sku name.

                                  • tier optional - string

                                    Specify public IP sku tier.

                          • subnet optional
                              • id optional - string

                                Resource Id

                  • networkSecurityGroup optional
                      • id optional - string

                        Resource Id

                  • primary optional - boolean

                    Specifies the primary network interface in case the virtual machine has more than 1 network interface.

          • networkInterfaces optional array
              • id optional - string

                Resource Id

              • properties optional
                  • deleteOption optional - string

                    Specify what happens to the network interface when the VM is deleted.

                  • primary optional - boolean

                    Specifies the primary network interface in case the virtual machine has more than 1 network interface.

      • osProfile optional
          • adminPassword optional - string

            Specifies the password of the administrator account. Minimum-length (Windows): 8 characters Minimum-length (Linux): 6 characters Max-length (Windows): 123 characters Max-length (Linux): 72 characters Complexity requirements: 3 out of 4 conditions below need to be fulfilled Has lower characters Has upper characters Has a digit Has a special character (Regex match [\W_]) Disallowed values: "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", "iloveyou!" For resetting the password, see How to reset the Remote Desktop service or its login password in a Windows VM For resetting root password, see Manage users, SSH, and check or repair disks on Azure Linux VMs using the VMAccess Extension

          • adminUsername optional - string

            Specifies the name of the administrator account. This property cannot be updated after the VM is created. Windows-only restriction: Cannot end in "." Disallowed values: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". Minimum-length (Linux): 1 character Max-length (Linux): 64 characters Max-length (Windows): 20 characters.

          • allowExtensionOperations optional - boolean

            Specifies whether extension operations should be allowed on the virtual machine. This may only be set to False when no extensions are present on the virtual machine.

          • computerName optional - string

            Specifies the host OS name of the virtual machine. This name cannot be updated after the VM is created. Max-length (Windows): 15 characters Max-length (Linux): 64 characters. For naming conventions and restrictions see Azure infrastructure services implementation guidelines.

          • customData optional - string

            Specifies a base-64 encoded string of custom data. The base-64 encoded string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum length of the binary array is 65535 bytes. Note: Do not pass any secrets or passwords in customData property This property cannot be updated after the VM is created. customData is passed to the VM to be saved as a file, for more information see Custom Data on Azure VMs For using cloud-init for your Linux VM, see Using cloud-init to customize a Linux VM during creation

          • linuxConfiguration optional
              • disablePasswordAuthentication optional - boolean

                Specifies whether password authentication should be disabled.

              • patchSettings optional
                  • assessmentMode optional - string

                    Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine. Possible values are: ImageDefault - You control the timing of patch assessments on a virtual machine. AutomaticByPlatform - The platform will trigger periodic patch assessments. The property provisionVMAgent must be true.

                  • patchMode optional - string

                    Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible. Possible values are: ImageDefault - The virtual machine's default patching configuration is used. AutomaticByPlatform - The virtual machine will be automatically updated by the platform. The property provisionVMAgent must be true.

              • provisionVMAgent optional - boolean

                Indicates whether virtual machine agent should be provisioned on the virtual machine. When this property is not specified in the request body, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later.

              • ssh optional
                  • publicKeys optional array
                      • keyData optional - string

                        SSH public key certificate used to authenticate with the VM through ssh. The key needs to be at least 2048-bit and in ssh-rsa format. For creating ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed).

                      • path optional - string

                        Specifies the full path on the created VM where ssh public key is stored. If the file already exists, the specified key is appended to the file. Example: /home/user/.ssh/authorized_keys

          • requireGuestProvisionSignal optional - boolean

            Specifies whether the guest provision signal is required to infer provision success of the virtual machine. Note: This property is for private testing only, and all customers must not set the property to false.

          • secrets optional array
              • sourceVault optional
                  • id optional - string

                    Resource Id

              • vaultCertificates optional array
                  • certificateStore optional - string

                    For Windows VMs, specifies the certificate store on the Virtual Machine to which the certificate should be added. The specified certificate store is implicitly in the LocalMachine account. For Linux VMs, the certificate file is placed under the /var/lib/waagent directory, with the file name <UppercaseThumbprint>.crt for the X509 certificate file and <UppercaseThumbprint>.prv for private key. Both of these files are .pem formatted.

                  • certificateUrl optional - string

                    This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see Add a key or secret to the key vault. In this case, your certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded in UTF-8: { "data":"<Base64-encoded-certificate>", "dataType":"pfx", "password":"<pfx-file-password>" } To install certificates on a virtual machine it is recommended to use the Azure Key Vault virtual machine extension for Linux or the Azure Key Vault virtual machine extension for Windows.

          • windowsConfiguration optional
              • additionalUnattendContent optional array
                  • componentName optional - string

                    The component name. Currently, the only allowable value is Microsoft-Windows-Shell-Setup.

                  • content optional - string

                    Specifies the XML formatted content that is added to the unattend.xml file for the specified path and component. The XML must be less than 4KB and must include the root element for the setting or feature that is being inserted.

                  • passName optional - string

                    The pass name. Currently, the only allowable value is OobeSystem.

                  • settingName optional - string

                    Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon.

              • enableAutomaticUpdates optional - boolean

                Indicates whether Automatic Updates is enabled for the Windows virtual machine. Default value is true. For virtual machine scale sets, this property can be updated and updates will take effect on OS reprovisioning.

              • patchSettings optional
                  • assessmentMode optional - string

                    Specifies the mode of VM Guest patch assessment for the IaaS virtual machine. Possible values are: ImageDefault - You control the timing of patch assessments on a virtual machine. AutomaticByPlatform - The platform will trigger periodic patch assessments. The property provisionVMAgent must be true.

                  • enableHotpatching optional - boolean

                    Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must be set to 'AutomaticByPlatform'.

                  • patchMode optional - string

                    Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible. Possible values are: Manual - You control the application of patches to a virtual machine. You do this by applying patches manually inside the VM. In this mode, automatic updates are disabled; the property WindowsConfiguration.enableAutomaticUpdates must be false AutomaticByOS - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. AutomaticByPlatform - the virtual machine will automatically updated by the platform. The properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true.

              • provisionVMAgent optional - boolean

                Indicates whether virtual machine agent should be provisioned on the virtual machine. When this property is not specified in the request body, default behavior is to set it to true. This will ensure that VM Agent is installed on the VM so that extensions can be added to the VM later.

              • timeZone optional - string

                Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". Possible values can be TimeZoneInfo.Id value from time zones returned by TimeZoneInfo.GetSystemTimeZones.

              • winRM optional
                  • listeners optional array
                      • certificateUrl optional - string

                        This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see Add a key or secret to the key vault. In this case, your certificate needs to be It is the Base64 encoding of the following JSON Object which is encoded in UTF-8: { "data":"<Base64-encoded-certificate>", "dataType":"pfx", "password":"<pfx-file-password>" } To install certificates on a virtual machine it is recommended to use the Azure Key Vault virtual machine extension for Linux or the Azure Key Vault virtual machine extension for Windows.

                      • protocol optional - string

                        Specifies the protocol of WinRM listener. Possible values are: http https.

      • platformFaultDomain optional - integer

        Specifies the scale set logical fault domain into which the Virtual Machine will be created. By default, the Virtual Machine will by automatically assigned to a fault domain that best maintains balance across available fault domains. <li>This is applicable only if the 'virtualMachineScaleSet' property of this Virtual Machine is set.<li>The Virtual Machine Scale Set that is referenced, must have 'platformFaultDomainCount' > 1.<li>This property cannot be updated once the Virtual Machine is created.<li>Fault domain assignment can be viewed in the Virtual Machine Instance View. Minimum api‐version: 2020‐12‐01

      • priority optional - string

        Specifies the priority for the virtual machine. Minimum api-version: 2019-03-01.

      • proximityPlacementGroup optional
          • id optional - string

            Resource Id

      • scheduledEventsProfile optional
          • terminateNotificationProfile optional
              • enable optional - boolean

                Specifies whether the Terminate Scheduled event is enabled or disabled.

              • notBeforeTimeout optional - string

                Configurable length of time a Virtual Machine being deleted will have to potentially approve the Terminate Scheduled Event before the event is auto approved (timed out). The configuration must be specified in ISO 8601 format, the default value is 5 minutes (PT5M)

      • securityProfile optional
          • encryptionAtHost optional - boolean

            This property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set. This will enable the encryption for all the disks including Resource/Temp disk at host itself. Default: The Encryption at host will be disabled unless this property is set to true for the resource.

          • securityType optional - string

            Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. Default: UefiSettings will not be enabled unless this property is set as TrustedLaunch.

          • uefiSettings optional
              • secureBootEnabled optional - boolean

                Specifies whether secure boot should be enabled on the virtual machine. Minimum api-version: 2020-12-01

              • vTpmEnabled optional - boolean

                Specifies whether vTPM should be enabled on the virtual machine. Minimum api-version: 2020-12-01

      • storageProfile optional
          • dataDisks optional array
              • caching optional - string

                Specifies the caching requirements. Possible values are: None ReadOnly ReadWrite Default: None for Standard storage. ReadOnly for Premium storage.

              • createOption required - string

                Specifies how the virtual machine should be created. Possible values are: Attach \u2013 This value is used when you are using a specialized disk to create the virtual machine. FromImage \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described.

              • deleteOption optional - string

                Specifies whether data disk should be deleted or detached upon VM deletion. Possible values: Delete If this value is used, the data disk is deleted when VM is deleted. Detach If this value is used, the data disk is retained after VM is deleted. The default value is set to detach.

              • detachOption optional - string

                Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: ForceDetach. detachOption: ForceDetach is applicable only for managed data disks. If a previous detachment attempt of the data disk did not complete due to an unexpected failure from the virtual machine and the disk is still not released then use force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'.

              • diskSizeGB optional - integer

                Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. This value cannot be larger than 1023 GB

              • image optional
                  • uri optional - string

                    Specifies the virtual hard disk's uri.

              • lun required - integer

                Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM.

              • managedDisk optional
                  • diskEncryptionSet optional
                      • id optional - string

                        Resource Id

                  • id optional - string

                    Resource Id

                  • storageAccountType optional - string

                    Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk.

              • name optional - string

                The disk name.

              • toBeDetached optional - boolean

                Specifies whether the data disk is in process of detachment from the VirtualMachine/VirtualMachineScaleset

              • vhd optional
                  • uri optional - string

                    Specifies the virtual hard disk's uri.

              • writeAcceleratorEnabled optional - boolean

                Specifies whether writeAccelerator should be enabled or disabled on the disk.

          • imageReference optional
              • id optional - string

                Resource Id

              • offer optional - string

                Specifies the offer of the platform image or marketplace image used to create the virtual machine.

              • publisher optional - string

                The image publisher.

              • sharedGalleryImageId optional - string

                Specified the shared gallery image unique id for vm deployment. This can be fetched from shared gallery image GET call.

              • sku optional - string

                The image SKU.

              • version optional - string

                Specifies the version of the platform image or marketplace image used to create the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest version of an image available at deploy time. Even if you use 'latest', the VM image will not automatically update after deploy time even if a new version becomes available.

          • osDisk optional
              • caching optional - string

                Specifies the caching requirements. Possible values are: None ReadOnly ReadWrite Default: None for Standard storage. ReadOnly for Premium storage.

              • createOption required - string

                Specifies how the virtual machine should be created. Possible values are: Attach \u2013 This value is used when you are using a specialized disk to create the virtual machine. FromImage \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described.

              • deleteOption optional - string

                Specifies whether OS Disk should be deleted or detached upon VM deletion. Possible values: Delete If this value is used, the OS disk is deleted when VM is deleted. Detach If this value is used, the os disk is retained after VM is deleted. The default value is set to detach. For an ephemeral OS Disk, the default value is set to Delete. User cannot change the delete option for ephemeral OS Disk.

              • diffDiskSettings optional
              • diskSizeGB optional - integer

                Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. This value cannot be larger than 1023 GB

              • encryptionSettings optional
                  • diskEncryptionKey optional
                      • secretUrl required - string

                        The URL referencing a secret in a Key Vault.

                      • sourceVault required
                          • id optional - string

                            Resource Id

                  • enabled optional - boolean

                    Specifies whether disk encryption should be enabled on the virtual machine.

                  • keyEncryptionKey optional
                      • keyUrl required - string

                        The URL referencing a key encryption key in Key Vault.

                      • sourceVault required
                          • id optional - string

                            Resource Id

              • image optional
                  • uri optional - string

                    Specifies the virtual hard disk's uri.

              • managedDisk optional
                  • diskEncryptionSet optional
                      • id optional - string

                        Resource Id

                  • id optional - string

                    Resource Id

                  • storageAccountType optional - string

                    Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk.

              • name optional - string

                The disk name.

              • osType optional - string

                This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. Possible values are: Windows Linux.

              • vhd optional
                  • uri optional - string

                    Specifies the virtual hard disk's uri.

              • writeAcceleratorEnabled optional - boolean

                Specifies whether writeAccelerator should be enabled or disabled on the disk.

      • userData optional - string

        UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. Minimum api-version: 2021-03-01

      • virtualMachineScaleSet optional
          • id optional - string

            Resource Id

  • tags optional - string

    Resource tags

  • type required - string
  • zones optional - array

    The virtual machine zones.

Frequently asked questions

What is Azure Compute Windows Virtual Machine?

Azure Compute Windows Virtual Machine is a resource for Compute of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Compute Windows Virtual Machine?

For Terraform, the rabindra-dahal/Terraform-resource-group-learning, karishma-sayeeda/challenge-kpmg and robertokiota/NetworkingModel source code examples are useful. See the Terraform Example section for further details.

For Azure Resource Manager, the maxskunkworks/TLG, maxskunkworks/TLG and maxskunkworks/TLG source code examples are useful. See the Azure Resource Manager Example section for further details.