Looking for an easy method to create a VM in Azure? Here are SIX methods to build your first Azure VM in no time!
Azure Virtual Machines (VMs) are an excellent way to scale apps, isolate them, and increase their performance. Azure VMs also offer the flexibility of virtualization without spending a cent on buying and maintaining the physical hardware running it.
These attractive features make Azure VMs among the most reliable ones you can find. So if you’re eager to create an efficient VM in Azure, keep reading as we show you six different methods to build your first Virtual Machine in Azure.
That being said, let’s dive right into it!
Table of Contents
Method 1: Create a Windows VM Using the Azure Portal
One of the simplest methods to create an Azure VM is via the Azure portal. This method offers you a browser-based UI to create your VM and its related resources.

Here’s how you can create an Azure VM using the Azure portal:
Step 1: Create A VM
1) Head to https://portal.azure.com and sign in to the Azure portal.
2) In the search, type virtual machines and hit enter.
3) Click on Virtual machines under Services.
4) Click on Create, which you can find on the Virtual machines page.
5) Select Azure virtual machine. You should be led to the Create a virtual machine page.
6) For the Virtual machine name, enter the desired VM name.
7) For the image, select the desired OS (i.e. Windows Server 2022 Datacenter – Gen 2).
8) Give a username and a password under the Administrator account. Ensure the password is at least 12 characters long and meets the other password criteria specified by Microsoft.
9) Click on Allow selected ports.
10) Choose to open the desired necessary ports only (i.e HTTP 80 or HTTPS 443). Do not expose management ports such as RDP port 3389 or SSH port 22 to the public Internet.
11) At the bottom of the page, click on Review + create.
12) Once validation has passed, click on Create at the bottom of the page.
13) Click on Go to resource once after deployment is complete.
Step 2: Connect To VM
Once the VM is created, you can connect to it by using many different methods:
1) Azure Bastion (the preferred option).
2) Using ExpressRoute, Site-to-Site or Point-to-Site VPN (recommended).
3) Using the public Internet over RDP or SSH ports (not recommended). If the VM is exposed to the Internet, then make sure to protect it using Just-In-Time VM access in Microsoft Defender for Cloud.
See Also: Migrate Gen1 to Gen2 VMs on Azure.
Method 2: Create a Windows VM Using PowerShell
Using the Azure portal is not the only way to create a Windows VM—you can also use the Azure PowerShell module to create your VM.
Here’s the simplest way to do it:
Step 1: Open Azure Cloud Shell
You can use the Azure Cloud Shell for free to create a VM in Azure, which features the most useful Azure tools configured and preinstalled to use with your account.
Opening the Cloud Shell is super easy; all you have to do is to find the upper right corner of a code block and click on Try it.
Alternatively, you can click here to open Cloud Shell in a separate browser tab. Copy the code block by clicking on Copy to. Then paste the link into the Cloud Shell and hit enter.
Step 2: Create An Azure Resource Group
While Azure resources are user-managed Azure entities (i.e., database, database server, or website), Azure resource groups are a collection of resources deployed as units. These units are essential to creating VMs using PowerShell.

So how can you create a resource group?
Simply use New-AzResourceGroup! This cmdlet enables you to create a resource group using only a location and name.
Step 3: Create A VM
After creating your resource group, the next step is to use New-AzVM to create a VM. When prompted, you’ll need to give a username & password for the Virtual Machine.
New-AzVM -Name AzVM01 -Credential (Get-Credential)
Congrats, you have successfully created a VM using PowerShell!
Related: Protect Hyper-V VM to Azure Backup with MARS Agent.
Method 3: Create a Windows VM Using Azure CLI
The third method to create a VM is through the Azure Command-Line Interface (CLI). The Azure CLI is simply a tool responsible for connecting to Azure and executing commands on Azure resources.
Here’s how to employ this tool to create a VM:
Step 1: Open Azure Cloud Shell
You can use the Azure Cloud Shell for free to create a VM in Azure, which features the most useful Azure tools configured and preinstalled to use with your account.
Opening the Cloud Shell is super easy; all you have to do is to find the upper right corner of a code block and click on Try it.
Alternatively, you can click here to open Cloud Shell in a separate browser tab. Copy the code blocks by clicking on Copy to, paste it into the Cloud Shell, and hit enter to start running the Cloud Shell.
Step 2: Create An Azure Resource Group
While Azure resources are user-managed Azure entities (i.e., database, database server, or website), Azure resource groups are a collection of resources deployed as units. These units are essential to creating VMs using PowerShell.
To create a resource group, you can simply use az group create.
az group create -l westus -n AzVMResourceGroup
Step 3: Create A VM
After creating your resource group, the next step is to use az vm create to create a VM.
az vm create -n AzVM01 -g VmResourceGroup --image Win2019Datacenter

When prompted, you’ll need to give a password that meets the specified requirements for Azure Virtual Machines provided below:
- It should be between 12-123 characters.
- It should have a digit.
- It should have upper characters.
- It should have lower characters.
- It should have a special character.
Once you finish creating a VM, you’ll be provided with a ‘publicIpAddress’ in the output, which you’ll need to use to access the VM.
To create a VM with a private IP address, you can use the following command:
az vm create -n AzVM01 -g VmResourceGroup --public-ip-address "" --image Win2019Datacenter
Creating a VM in Azure makes RDP connections open by default. If you need to open another port, you’ll need to use az vm open-port cmdlet.
az vm open-port -g VmResourceGroup -n AzVM01 --port 443 --priority 100
Method 4: Create Azure VM Using Azure Resource Manager Template
The Azure Resource Manager template (ARM template) is the final method to create a VM in Azure. An ARM template is basically a JSON file responsible for defining the configuration and infrastructure for your project.
This template is based on declarative syntax, which enables you to describe the deployment method without writing the sequence of programming commands.

So, here’s the quickest way to create a VM using an ARM template:
Step 1: Review the Template
In this step, you can use Azure Quickstart Templates to use an existing ARM template, review it, and customize it if needed.
Step 2: Deploy the Template
Follow these steps to deploy the ARM template:
1) Click here to sign in to Azure and open a template.
2) Choose an Azure subscription (subscription field).
3) Choose an existing resource group or create a new one. Give the resource group a unique name and select OK (resource group field).
4) Choose a location.
5) Type a username.
6) Type a password for the admin account. It should have a digit, upper, lower, and special characters.
7) Provide a unique identifier (DNS label prefix field).
8) Choose the version of Windows you want to run on the Virtual Machine.
9) Choose the size of the VM.
10) If a resource group already exists, the default location will be the same as the resource group.
11) Click on Review + create.
12) Create and deploy the VM by clicking on Create.
Step 3: Review Resources
After successfully deploying the template, you can check on the VM and other resources using the Azure portal—simply click on Go to resource group to review the deployed resources.
Method 5: Create Azure VM using a Bicep File
You can also create a VM using a Bicep file. In case you don’t know, Bicep is basically a DSL that deploys Azure resources through declarative syntax.
Bicep has multiple benefits; it supports code reuse, reliable type safety, and concise syntax.
Note that this method requires you to have an Azure subscription. With this in mind, here’s how to create a Windows VM using a Bicep file in 3 easy steps:
Step 1: Review the Bicep File
In this step, you’ll have to create multiple resources: a subnet, storage account, public IP address, network security group, virtual network, NIC, and virtual machine.
Step 2: Deploy the Bicep File
To deploy the Bicep file, you’ll have to save it to your local computer as main.bicep. then use Azure CLI or Azure PowerShell to deploy it.
You also want to write a unique username instead of <admin-username>. Finally, give a password of at least 12 characters when prompted. A message indicating the process succeeded should then appear to you.
Step 3: Review the Deployed Resources
Next, list the deployed resources in the resource group with Azure CLI, Azure PowerShell, or Azure portal.
Method 6: Create Azure VM using Terraform
Finally, you can create an Azure VM using Terraform. In case you don’t know, Terraform is basically an Infrastructure as Code (IaC) from HashiCorp that helps you to provision resources in Azure with a very simple language.

Terraform is a Multi-Cloud provider that works with (Azure, AWS, Google Cloud, Ali Cloud, etc). It is a multi-platform that can run on (Windows, Linux, macOS, FreeBSD, OpenBSD, and Solaris), and it’s open source with a large active community.
Note that this method requires you to have an Azure subscription, and install/configure Terraform and Terraform provider versions on your machine.
With this in mind, here’s how to create a Windows VM using Terraform in 4 easy steps:
Step 1: Implement the Terraform code
First, you need to create a directory in which to save the sample Terraform code and make it the current directory.
Then create a file named main.tf, save it in the directory and then insert the example code from here.
The main.tf will contain the main set of configurations for your VM deployment. You can also create other configuration files and organize them however makes sense for your project.
Step 2: Initialize Terraform
Next, you need to run terraform init to initialize the Terraform deployment. This command downloads the Azure modules required to manage your Azure resources.
terraform init
Step 3: Create a Terraform execution plan
Run terraform plan to create an execution plan.
terraform plan -out main.tfplan
Step 4: Apply a Terraform
Run terraform apply to apply the execution plan to your Azure infrastructure.
terraform apply main.tfplan
Final Thoughts
After learning the six methods of creating a VM in Azure, we bet you feel like a Virtual Machine expert. But before you rush into creating your VM in Azure, you need to consider a few things, like the VM size, OS, network settings, and security.
These factors affect your VM experience with Azure, which we will cover in other Azure guides. But once your VM is created, you can connect to it and install any applications or services you need. The sky is your limit!
FAQs
Does Azure VM cost when stopped?
No, you won’t be charged for the VM compute resources when your Azure VM is in the “Stopped/Deallocated” state. However, you’ll still need to pay for any data storage disks and OS attached to your VM.
Which VM is free in Azure?
With the free account, you can only access 1 type of Virtual Machine for free, the B1S Burstable B series. You can use the free services in different configurations while staying within the free account limits.
How many Virtual Machines can I run in Azure?
Azure enables you to create and run hundreds of VMs in the same subscription.
The following limits apply when you use Azure Resource Manager: 25,000 VMs per subscription and per region.
What are the limitations of Windows Azure VM?
You can create a username maximum of 20 characters in length without ending in a period (“.”).
Can I delete VM permanently in Azure?
Yes. You can set your VM to either Delete (which deletes the resource permanently) or Detach (which detaches the resource while keeping it in Azure for later use).
Can multiple users use the same VM?
Azure does not allow multiple users to access the same VM by default. You will need to purchase an RDS license and set up an RDS server to allow multiple users to connect to your VM. The server issues client access licenses to various devices and users to grant access.
By default, you can have 2 simultaneous users accessing Azure VM.
What is Azure VM size?
A VM in Azure has up to 672 GiB of RAM. It also can scale up to 104 vCPUs on isolated instances and provides sizes with/without local temporary storage.
Can I change the Azure VM size?
Yes. Follow these steps to change your VM size in Azure:
- Open the Azure portal.
- Open the VM page.
- Click on Size in the left menu blade.
- Choose your preferred VM size.
- Click on Resize.
__
Thank you for reading my blog.
If you have any questions or feedback, please leave a comment.
-Charbel Nemnom-