|
| 1 | +--- |
| 2 | +title: 'Quickstart: Use a Bicep file to create a Windows VM' |
| 3 | +description: In this quickstart, you learn how to use a Bicep file to create a Windows virtual machine |
| 4 | +author: schaffererin |
| 5 | +ms.service: virtual-machines |
| 6 | +ms.collection: windows |
| 7 | +ms.topic: quickstart |
| 8 | +ms.workload: infrastructure |
| 9 | +ms.date: 03/11/2022 |
| 10 | +ms.author: v-eschaffer |
| 11 | +ms.custom: subject-armqs, mode-arm |
| 12 | +--- |
| 13 | + |
| 14 | +# Quickstart: Create a Windows virtual machine using a Bicep file |
| 15 | + |
| 16 | +**Applies to:** :heavy_check_mark: Windows VMs |
| 17 | + |
| 18 | +This quickstart shows you how to use a Bicep file to deploy a Windows virtual machine (VM) in Azure. |
| 19 | + |
| 20 | +[!INCLUDE [About Bicep](../../../includes/resource-manager-quickstart-bicep-introduction.md)] |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin. |
| 25 | + |
| 26 | +## Review the Bicep file |
| 27 | + |
| 28 | +The Bicep file used in this quickstart is from [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates/vm-simple-windows/). |
| 29 | + |
| 30 | +:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.compute/vm-simple-windows/main.bicep"::: |
| 31 | + |
| 32 | +Several resources are defined in the Bicep file: |
| 33 | + |
| 34 | +- [**Microsoft.Network/virtualNetworks/subnets**](/azure/templates/Microsoft.Network/virtualNetworks/subnets): create a subnet. |
| 35 | +- [**Microsoft.Storage/storageAccounts**](/azure/templates/Microsoft.Storage/storageAccounts): create a storage account. |
| 36 | +- [**Microsoft.Network/publicIPAddresses**](/azure/templates/Microsoft.Network/publicIPAddresses): create a public IP address. |
| 37 | +- [**Microsoft.Network/networkSecurityGroups**](/azure/templates/Microsoft.Network/networkSecurityGroups): create a network security group. |
| 38 | +- [**Microsoft.Network/virtualNetworks**](/azure/templates/Microsoft.Network/virtualNetworks): create a virtual network. |
| 39 | +- [**Microsoft.Network/networkInterfaces**](/azure/templates/Microsoft.Network/networkInterfaces): create a NIC. |
| 40 | +- [**Microsoft.Compute/virtualMachines**](/azure/templates/Microsoft.Compute/virtualMachines): create a virtual machine. |
| 41 | + |
| 42 | +## Deploy the Bicep file |
| 43 | + |
| 44 | +1. Save the Bicep file as **main.bicep** to your local computer. |
| 45 | +1. Deploy the Bicep file using either Azure CLI or Azure PowerShell. |
| 46 | + |
| 47 | + # [CLI](#tab/CLI) |
| 48 | + |
| 49 | + ```azurecli |
| 50 | + az group create --name exampleRG --location eastus |
| 51 | + az deployment group create --resource-group exampleRG --template-file main.bicep --parameters adminUsername=<admin-username> |
| 52 | + ``` |
| 53 | +
|
| 54 | + # [PowerShell](#tab/PowerShell) |
| 55 | +
|
| 56 | + ```azurepowershell |
| 57 | + New-AzResourceGroup -Name exampleRG -Location eastus |
| 58 | + New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -adminUsername "<admin-username>" |
| 59 | + ``` |
| 60 | +
|
| 61 | + --- |
| 62 | +
|
| 63 | + > [!NOTE] |
| 64 | + > Replace **\<admin-username\>** with a unique username. You'll also be prompted to enter adminPassword. The minimum password length is 12 characters. |
| 65 | +
|
| 66 | + When the deployment finishes, you should see a messaged indicating the deployment succeeded. |
| 67 | +
|
| 68 | +## Review deployed resources |
| 69 | +
|
| 70 | +Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group. |
| 71 | +
|
| 72 | +# [CLI](#tab/CLI) |
| 73 | +
|
| 74 | +```azurecli-interactive |
| 75 | +az resource list --resource-group exampleRG |
| 76 | +``` |
| 77 | + |
| 78 | +# [PowerShell](#tab/PowerShell) |
| 79 | + |
| 80 | +```azurepowershell-interactive |
| 81 | +Get-AzResource -ResourceGroupName exampleRG |
| 82 | +``` |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## Clean up resources |
| 87 | + |
| 88 | +When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the VM and all of the resources in the resource group. |
| 89 | + |
| 90 | +# [CLI](#tab/CLI) |
| 91 | + |
| 92 | +```azurecli-interactive |
| 93 | +az group delete --name exampleRG |
| 94 | +``` |
| 95 | + |
| 96 | +# [PowerShell](#tab/PowerShell) |
| 97 | + |
| 98 | +```azurepowershell-interactive |
| 99 | +Remove-AzResourceGroup -Name exampleRG |
| 100 | +``` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Next steps |
| 105 | + |
| 106 | +In this quickstart, you deployed a simple virtual machine using a Bicep file. To learn more about Azure virtual machines, continue to the tutorial for Linux VMs. |
| 107 | + |
| 108 | +> [!div class="nextstepaction"] |
| 109 | +> [Azure Windows virtual machine tutorials](./tutorial-manage-vm.md) |
0 commit comments