Quickstart: Create a Windows virtual machine using an ARM template

Applies to: ✔️ Windows VMs

This quickstart shows you how to utilize an Azure Resource Managing director template (ARM template) to deploy a Windows virtual machine (VM) in Azure.

An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your surroundings meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Deploy to Azure

Prerequisites

If you don't have an Azure subscription, create a free account earlier you begin.

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

              {   "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",   "contentVersion": "1.0.0.0",   "metadata": {     "_generator": {       "name": "bicep",       "version": "0.iv.613.9944",       "templateHash": "7822315097766237434"     }   },   "parameters": {     "adminUsername": {       "type": "cord",       "metadata": {         "description": "Username for the Virtual Automobile."       }     },     "adminPassword": {       "type": "secureString",       "minLength": 12,       "metadata": {         "description": "Countersign for the Virtual Machine."       }     },     "dnsLabelPrefix": {       "type": "string",       "defaultValue": "[toLower(format('{0}-{1}', parameters('vmName'), uniqueString(resourceGroup().id, parameters('vmName'))))]",       "metadata": {         "clarification": "Unique DNS Name for the Public IP used to access the Virtual Machine."       }     },     "publicIpName": {       "type": "string",       "defaultValue": "myPublicIP",       "metadata": {         "description": "Name for the Public IP used to admission the Virtual Auto."       }     },     "publicIPAllocationMethod": {       "blazon": "string",       "defaultValue": "Dynamic",       "allowedValues": [         "Dynamic",         "Static"       ],       "metadata": {         "description": "Allocation method for the Public IP used to admission the Virtual Machine."       }     },     "publicIpSku": {       "type": "string",       "defaultValue": "Basic",       "allowedValues": [         "Basic",         "Standard"       ],       "metadata": {         "clarification": "SKU for the Public IP used to access the Virtual Auto."       }     },     "OSVersion": {       "type": "string",       "defaultValue": "2019-datacenter-gensecond",       "allowedValues": [         "2019-datacenter-gensecond",         "2019-datacenter-cadre-gensecond",         "2019-datacenter-core-smalldisk-gensecond",         "2019-datacenter-core-with-containers-gensecond",         "2019-datacenter-core-with-containers-smalldisk-g2",         "2019-datacenter-smalldisk-gensecond",         "2019-datacenter-with-containers-gensecond",         "2019-datacenter-with-containers-smalldisk-g2",         "2016-datacenter-gensecond"       ],       "metadata": {         "description": "The Windows version for the VM. This will pick a fully patched Gen2 image of this given Windows version."       }     },     "vmSize": {       "type": "cord",       "defaultValue": "Standard_D2s_v3",       "metadata": {         "description": "Size of the virtual car."       }     },     "location": {       "type": "string",       "defaultValue": "[resourceGroup().location]",       "metadata": {         "description": "Location for all resources."       }     },     "vmName": {       "type": "string",       "defaultValue": "unproblematic-vm",       "metadata": {         "clarification": "Name of the virtual machine."       }     }   },    "variables": {     "storageAccountName": "[format('bootdiags{0}', uniqueString(resourceGroup().id))]",     "nicName": "myVMNic",     "addressPrefix": "10.0.0.0/16",     "subnetName": "Subnet",     "subnetPrefix": "x.0.0.0/24",     "virtualNetworkName": "MyVNET",     "networkSecurityGroupName": "default-NSG"   },   "resource": [     {       "type": "Microsoft.Storage/storageAccounts",       "apiVersion": "2021-04-01",       "proper noun": "[variables('storageAccountName')]",       "location": "[parameters('location')]",       "sku": {         "proper noun": "Standard_LRS"       },       "kind": "Storage"     },     {       "type": "Microsoft.Network/publicIPAddresses",       "apiVersion": "2021-02-01",       "name": "[parameters('publicIpName')]",       "location": "[parameters('location')]",       "sku": {         "name": "[parameters('publicIpSku')]"       },       "properties": {         "publicIPAllocationMethod": "[parameters('publicIPAllocationMethod')]",         "dnsSettings": {           "domainNameLabel": "[parameters('dnsLabelPrefix')]"         }       }     },     {       "blazon": "Microsoft.Network/networkSecurityGroups",       "apiVersion": "2021-02-01",       "proper name": "[variables('networkSecurityGroupName')]",       "location": "[parameters('location')]",       "backdrop": {         "securityRules": [           {             "proper noun": "default-permit-3389",             "backdrop": {               "priority": 1000,               "access": "Allow",               "management": "Inbound",               "destinationPortRange": "3389",               "protocol": "Tcp",               "sourcePortRange": "*",               "sourceAddressPrefix": "*",               "destinationAddressPrefix": "*"             }           }         ]       }     },     {       "type": "Microsoft.Network/virtualNetworks",       "apiVersion": "2021-02-01",       "name": "[variables('virtualNetworkName')]",       "location": "[parameters('location')]",       "backdrop": {         "addressSpace": {           "addressPrefixes": [             "[variables('addressPrefix')]"           ]         },         "subnets": [           {             "name": "[variables('subnetName')]",             "properties": {               "addressPrefix": "[variables('subnetPrefix')]",               "networkSecurityGroup": {                 "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"               }             }           }         ]       },       "dependsOn": [         "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"       ]     },     {       "blazon": "Microsoft.Network/networkInterfaces",       "apiVersion": "2021-02-01",       "proper name": "[variables('nicName')]",       "location": "[parameters('location')]",       "backdrop": {         "ipConfigurations": [           {             "proper name": "ipconfig1",             "backdrop": {               "privateIPAllocationMethod": "Dynamic",               "publicIPAddress": {                 "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]"               },               "subnet": {                 "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"               }             }           }         ]       },       "dependsOn": [         "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]",         "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"       ]     },     {       "blazon": "Microsoft.Compute/virtualMachines",       "apiVersion": "2021-03-01",       "proper name": "[parameters('vmName')]",       "location": "[parameters('location')]",       "properties": {         "hardwareProfile": {           "vmSize": "[parameters('vmSize')]"         },         "osProfile": {           "computerName": "[parameters('vmName')]",           "adminUsername": "[parameters('adminUsername')]",           "adminPassword": "[parameters('adminPassword')]"         },         "storageProfile": {           "imageReference": {             "publisher": "MicrosoftWindowsServer",             "offering": "WindowsServer",             "sku": "[parameters('OSVersion')]",             "version": "latest"           },           "osDisk": {             "createOption": "FromImage",             "managedDisk": {               "storageAccountType": "StandardSSD_LRS"             }           },           "dataDisks": [             {               "diskSizeGB": 1023,               "lun": 0,               "createOption": "Empty"             }           ]         },         "networkProfile": {           "networkInterfaces": [             {               "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"             }           ]         },         "diagnosticsProfile": {           "bootDiagnostics": {             "enabled": true,             "storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob]"           }         }       },       "dependsOn": [         "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",         "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"       ]     }   ],   "outputs": {     "hostname": {       "type": "string",       "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))).dnsSettings.fqdn]"     }   } }                          

Several resources are divers in the template:

  • Microsoft.Network/virtualNetworks/subnets: create a subnet.
  • Microsoft.Storage/storageAccounts: create a storage account.
  • Microsoft.Network/publicIPAddresses: create a public IP accost.
  • Microsoft.Network/networkSecurityGroups: create a network security group.
  • Microsoft.Network/virtualNetworks: create a virtual network.
  • Microsoft.Network/networkInterfaces: create a NIC.
  • Microsoft.Compute/virtualMachines: create a virtual machine.

Deploy the template

  1. Select the following image to sign in to Azure and open a template. The template creates a key vault and a secret.

    Deploy to Azure

  2. Select or enter the post-obit values. Use the default values, when available.

    • Subscription: select an Azure subscription.
    • Resource group: select an existing resources group from the drop-down, or select Create new, enter a unique name for the resources group, and then click OK.
    • Location: select a location. For example, Central US.
    • Admin username: provide a username, such every bit azureuser.
    • Admin countersign: provide a countersign to employ for the admin account. The password must exist at to the lowest degree 12 characters long and meet the divers complexity requirements.
    • DNS label prefix: enter a unique identifier to use as part of the DNS label.
    • Windows OS version: select which version of Windows you want to run on the VM.
    • VM size: select the size to use for the VM.
    • Location: the default is the same location equally the resource group, if information technology already exists.
  3. Select Review + create. After validation completes, select Create to create and deploy the VM.

The Azure portal is used to deploy the template. In addition to the Azure portal, you can too employ the Azure PowerShell, Azure CLI, and Remainder API. To learn other deployment methods, see Deploy templates.

Review deployed resource

Yous tin can apply the Azure portal to check on the VM and other resources that were created. Afterwards the deployment is finished, select Go to resource grouping to encounter the VM and other resources.

Clean upward resources

When no longer needed, delete the resource group, which deletes the VM and all of the resources in the resources group.

  1. Select the Resource group.
  2. On the page for the resource grouping, select Delete.
  3. When prompted, type the name of the resource group and so select Delete.

Next steps

In this quickstart, you deployed a uncomplicated virtual motorcar using an ARM template. To larn more than near Azure virtual machines, go on to the tutorial for Linux VMs.