
In this azure tutorial, we will discuss How to How to Create Azure VM (Virtual Machine). Apart from this, we will also discuss on the below topics
- How to create a free virtual machine in the Azure
- Virtual machine in azure
- How to create an Azure virtual machine by using PowerShell
- How to create a windows virtual machine (VM) in Azure
- Create an Azure virtual machine by using PowerShell
- Azure Create VM PowerShell
- How To Create A Virtual Machine Using Azure CLI
- How To Create Linux VM In Azure
- How To Create Virtual Machine In Azure Step By Step
- Create Linux VM Using Azure CLI
- Command To Create Virtual Machine In Azure
- az vm create
Table of Contents
- How to Create Azure VM (Virtual Machine)
- How To Create Free Virtual Machine In Azure
- How to create an Azure VM (virtual machine) using PowerShell
- Azure Create VM PowerShell
- How To Create A Virtual Machine Using Azure CLI
- How To Create Linux VM In Azure
- How To Create Virtual Machine In Azure Step By Step
- Create Linux VM Using Azure CLI
- Command To Create Virtual Machine In Azure
- az vm create
- Create Azure VM (Virtual Machine) – Video Tutorial
How to Create Azure VM (Virtual Machine)
We can create a Windows virtual machine (VM) in Microsoft Azure for free or How to create a free Azure VM
Note: To create an Azure VM for free, you can sign up for a 30-days Azure free trial.
How To Create Free Virtual Machine In Azure
Follow the below steps to create a virtual machine in Azure.
Here, we will discuss to Create the Virtual Machine with the new version of Windows Server 2019 Datacenter.
Make sure you have a subscription to Azure before starting. If you don’t have a subscription then create a free Azure account.
- How To Create Azure Windows Virtual Machine From A Snapshot PowerShell
- Azure Virtual Machine Tutorial
- How to access Azure VM (Virtual Machine)
- Azure virtual machine auto shutdown
Assuming you have an Azure subscription now. Follow the below steps to create a Windows virtual machine.
Step-1: Login to https://portal.azure.com.
Step-2: Now click on the “Virtual machines” option from the left side Menu and then click on the “Create” link.

Or Go to the “Virtual machines” option from the “Azure services” section.

One more way is to go to the same option from the “Create a resource” link from the left side menu and then select the “Compute” and “Virtual machine”.


Or else for the same option you can go to the “Create a resource” link from the “Azure services” section and then select the “Compute” and “Virtual machine”.

You can see the option “Virtual machine’ like below:

Step- 3: Fill the details required. A few of the options you can keep as it is but based on your business need you can change those.
- Subscription: Choose your correct subscription.
- Resource group: You can choose the existing resource group or you can create a new one by clicking the “Create New” option. It acts like a container that stores the resources related to an Azure solution.
- Virtual machine name: Provide a name for your virtual machine.
- Region: This the location where you are going to create all the resources related to the virtual machine.
- Image: Choose the Windows Server 2019 Datacenter. You can change it based on your business need.
- Size: The size you want to assign based on your requirement. I have chosen Standard D2s v3 as per my business requirement.
In the Administrator account section, Choose a Username, Password that you will use to login to the VM once created.
Select Inbound port: Choose HTTP(80),RDP(3389). This is a very important option.
All other options you can keep as it is. Now click on “Next:Disks >” button.


Since, I do not have a windows server license, you can select No license.

In the next screen (Disks), you can add the disk architecture that you want. I kept the default option as it is. You can change it based on your business need. Click on Next: Networking button.

Now you can fill the below details in the Networking screen.
- Virtual Network: Choose a virtual network or else you can create a new one by clicking the “Create New” link.
- Subnet: You can keep the default option as it is.
- Public inbound ports: choose Allow selected ports.
- Select inbound ports: This is a very important option. Choose the option as HTTP(80), RDP(3389) here. Once you choose this option in the Basics tab it will automatically show the same option here. Keep the option as it is.


Now for other tabs all the options you can keep as it is. Once you fill all the above details click on the “Review + Create” button. Azure will validates the above details internally and will show a message “Validation passed”.

Step- 4: Now click on the “Create” button. It will show you “Your deployment is complete“.Now click on “Go to resource”

Step- 5: Congratulations, Now you have created the VM successfully. Click on the Connect button to connect to the VM.

Well, we discussed How to Create Azure VM (Virtual Machine)
How to create an Azure VM (virtual machine) using PowerShell
Above, we discussed How to Create Azure VM (Virtual Machine) using Azure Portal. Let’s see here how to to create an Azure VM (virtual machine) by using PowerShell.
Azure Create VM PowerShell
To start with make sure you have installed Azure PowerShell Az 1.0 or later version. You can use the below command
Install-Module Az
Now Login to your Azure account
Login-AzAccount
user object creation
$credentials = Get-Credential -Message "Enter your username and password for the virtual machine."
Resource group creation
$vmresourceGroup = "MyDev"
$location = "(Asia pacific) Central India"
New-AzureRmResourceGroup -Name $vmresourceGroup -Location $location
Subnet configuration
$SubnetName = "Mydevsubnet"
$subnetConfiguration = New-AzureRmVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix 10.50.1.0/24
Virtual Network creation
$Networkname = "DevNet"
$vmresourceGroup = "MyDev"
$Devnet = New-AzureRmVirtualNetwork -ResourceGroupName $vmresourceGroup-Location $location -Name $Networkname -AddressPrefix 10.50.1.0/24 -Subnet $subnetConfiguration
Public IP Address creation
$vmresourceGroup = "MyDev"
$location = "(Asia pacific) Central India"
$publicdn = "dev-cdn"
$publicIP = New-AzureRmPublicIpAddress -ResourceGroupName $vmresourceGroup -Location $location -Name "$publicdn$(Get-Random)" -AllocationMethod Static -IdleTimeoutInMinutes 5
Rule for Port 3389
$NameRDP = "Default-RDP"
$location = "(Asia pacific) Central India"
$portRule = New-AzureRmNetworkSecurityRuleConfig -Name $NameRDP -Protocol Tcp -Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389 -Access Allow
Network security group creation
$SecurityGroupName = "DevNetworkSecurity"
$location = "(Asia pacific) Central India"
$securitygroup = New-AzureRmNetworkSecurityGroup -ResourceGroupName $vmresourceGroup -Location $location
-Name $SecurityGroupName -SecurityRules $portRule
Virtual network card creation
$NameNetworkCard = "DevNetworkCard"
$location = "(Asia pacific) Central India"
$networkcard = New-AzureRmNetworkInterface -Name $NameNetworkCard -ResourceGroupName $vmresourceGroup -Location $location -SubnetId $Devnet.Subnets[0].Id -PublicIpAddressId $publicIP.Id -NetworkSecurityGroupId $securitygroup.Id
Virtual machine configuration
$vmName = "MyAzureVM"
$MYVMSize = "Standard_D1_v2"
$vmConfiguration = New-AzureRmVMConfig -VMName $vmName -VMSize $MYVMSize | Set-AzureRmVMOperatingSystem -Windows -ComputerName $vmName -Credential $credentials | Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsServer - WindowsServer -Skus 2019 -Datacenter -Version latest | Add-AzureRmVMNetworkInterface -Id $networkcard.Id
VM Creation
New-AzureRmVM -ResourceGroupName $vmresourceGroup -Location $location -VM $vmConfiguration
Now here is the complete Script
$vmresourceGroup = "MyDev"
$location = "(Asia pacific) Central India"
$SubnetName = "Mydevsubnet"
$NameRDP = "Default-RDP"
$SecurityGroupName = "DevNetworkSecurity"
$vmName = "MyAzureVM"
$MYVMSize = "Standard Ds1_v2"
$Networkname = "DevNet"
$NameNetworkCard = "DevNetworkCard"
$publicdn = "dev-cdn"
$credentials = Get-Credential -Message "Enter your username and password for the virtual machine."
New-AzureRmResourceGroup -Name $vmresourceGroup -Location $location
$subnetConfiguration = New-AzureRmVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix 10.50.1.0/24
$Devnet = New-AzureRmVirtualNetwork -ResourceGroupName $vmresourceGroup-Location $location -Name $Networkname -AddressPrefix 10.50.1.0/24 -Subnet $subnetConfiguration
$publicIP = New-AzureRmPublicIpAddress -ResourceGroupName $vmresourceGroup -Location $location -Name "$publicdn$(Get-Random)" -AllocationMethod Static -IdleTimeoutInMinutes 5
$portRule = New-AzureRmNetworkSecurityRuleConfig -Name $NameRDP -Protocol Tcp -Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389 -Access Allow
$securitygroup = New-AzureRmNetworkSecurityGroup -ResourceGroupName $vmresourceGroup -Location $location
-Name $SecurityGroupName -SecurityRules $portRule
$networkcard = New-AzureRmNetworkInterface -Name $NameNetworkCard -ResourceGroupName $vmresourceGroup -Location $location -SubnetId $Devnet.Subnets[0].Id -PublicIpAddressId $publicIP.Id -NetworkSecurityGroupId $securitygroup.Id
$vmConfiguration = New-AzureRmVMConfig -VMName $vmName -VMSize $MYVMSize | Set-AzureRmVMOperatingSystem -Windows -ComputerName $vmName -Credential $credentials | Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsServer - WindowsServer -Skus 2019 -Datacenter -Version latest | Add-AzureRmVMNetworkInterface -Id $networkcard.Id
New-AzureRmVM -ResourceGroupName $vmresourceGroup -Location $location -VM $vmConfiguration
How To Create A Virtual Machine Using Azure CLI
Well, You can also quickly able to create a VM using Azure CLI. Use the below steps to create a virtual machine using Azure CLI.
Step-1: Create a resource group using the below command in Azure CLI.
az group create --name myRsgGroup --location eastus
Once you will execute the above command, you will get the output like below
{
"id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/myRsgGroup",
"location": "eastus",
"managedBy": null,
"name": "myRsgGroup",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
Step-2: Now, run the below command to create the VM in using Azure CLI.
az vm create --resource-group myRsgGroup --name TSINFOVM2 --image Win2016Datacenter --admin-username rajkishore --admin-password "Password@123" --location eastus
You can see it as below

Once You will execute the above command, you will get the output like below
{- Finished ..
"fqdns": "",
"id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/myRsgGroup/providers/Microsoft.Compute/virtualMachines/TSINFOVM2",
"location": "eastus",
"macAddress": "00-0D-3A-18-68-6B",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "13.92.35.98",
"resourceGroup": "myRsgGroup",
"zones": ""
}
Now, if you will verify on the Azure Portal, you can able to see the VM created successfully.

How To Create Linux VM In Azure
Well, we have discussed above, How to create a Windows virtual machine in the Azure portal. Now let’s discuss here, how to create Linux Virtual Machine in Azure.
How To Create Virtual Machine In Azure Step By Step
Step-1: Follow the step-1 to Step-2 from the above section.
Step-2: On the Create a Virtual Machine page, Provide the below details
- Subscription: Select a valid subscription that you want to use here to create a Linux virtual machine.
- Resource group: Choose the existing resource group or you can create a new one by clicking the “Create New” option.
- Virtual machine name: You need to provide a name for your virtual machine.
- Region: Select the region or location.
- Image: Choose the Ubuntu Server 20.04 LTS – Gen1 as the image option.
- Size: Select the size based on your business requirement. Click on the see all sizes link to check all the options available.
- Authentication Type: Select the authentication type based on your need.
- Username: Provide a username.
- SSH public key source: Select the default option Generate new key pair.
- Key Pair Name: Provide a name for the key pair.
- Public inbound Ports: Select the Allow selected ports option.
- Select Inbound Ports: Select the HTTP (80), SSH (22) option.
Keep the other tab values as it is, Finally click on the Review + Create button.



Step-3: Now, it will validate all the details provided by you and will show you Validation Passed. Click on the Create button to create the Azure Linux Virtual Machine.
Step-4: Click on the Download private key and create resource button to download the key details that you need while connecting the virtual machine.

Step-5: It will take a few minutes and then will show you that Your deployment is complete. Click on the Go to Resource button to navigate to the Linux Virtual Machine that you have created.

Create Linux VM Using Azure CLI
You can easily create a linux virtual machine using Azure CLI by using the below steps.
Step-1: Run the below command to create a Resource Group using Azure CLI.
az group create --name demoRsgGroup --location eastus
Once, you will execute the above command, you will get the output like below
{
"id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/demoRsgGroup",
"location": "eastus",
"managedBy": null,
"name": "demoRsgGroup",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
Step-2: Now, execute the below command to create the VM using Azure CLI.
az vm create --resource-group demoRsgGroup --name TSINFOVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
You can able to see it as below

Once You will execute the above command, you will get the output like below
{- Finished ..
"fqdns": "",
"id": "/subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroups/demoRsgGroup/providers/Microsoft.Compute/virtualMachines/TSINFOVM",
"location": "eastus",
"macAddress": "00-0D-3A-57-3D-13",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "52.179.10.61",
"resourceGroup": "demoRsgGroup",
"zones": ""
}
Now, to verify, you can navigate to the Azure Portal and can able to see the below Azure Linux VM created successfully.

Command To Create Virtual Machine In Azure
You can use below command in Azure CLI to create the Azure Virtual Machine.
az vm create --resource-group Resource Group Name --name VM Name --image Win2016Datacenter --admin-username User Name --admin-password "Your Password" --location Location Name
Or,
New-AzVM
PowerShell command to create VM in Azure is as below. Refer to the above section for the complete details.
New-AzureRmVM -ResourceGroupName $vmresourceGroup -Location $location -VM $vmConfiguration
az vm create
You can use the az vm create command to quickly create an Azure Virtual machine using Azure CLI.
Syntax:
The syntax is as below
az vm create --resource-group Resource Group Name --name VM Name --image Win2016Datacenter --admin-username User Name --admin-password "Your Password" --location Location Name
Example:
Consider the below example
az vm create --resource-group myRsgGroup --name TSINFOVM2 --image Win2016Datacenter --admin-username rajkishore --admin-password "Password@123" --location eastus
In the above example.
- myRsgGroup — The name of the Resource Group.
- TSINFOVM2 — Virtual machine name.
- Win2016Datacenter — Image name.
- rajkishore–The local admin username for the VM.
- Password@123 –The local admin password for the Virtual Machine.
- eastus — The location name.
Create Azure VM (Virtual Machine) – Video Tutorial
You may like following Azure tutorials:
- What is the Azure Active Directory and how Azure AD works?
- What is Azure Active Directory B2B collaboration (Azure AD B2B)
- How to add bulk guest users in Azure AD B2B from Azure Portal and PowerShell
- Azure active directory premium features
- Microsoft Azure Free Training (Get a free voucher for AZ-900 Certification)
- How to Connect to Azure in PowerShell (And Azure AD)
- the term ‘get-aduser’ is not recognized as the name of a cmdlet windows 2016
- How to create a user in azure active directory
Conclusion
In this Azure tutorial, we have discussed on the below topics:
- How to Create Azure VM (Virtual Machine)
- Virtual machine in azure
- How To Create Free Virtual Machine In Azure
- How to create a windows virtual machine (VM) in Azure
- Create an Azure virtual machine by using PowerShell
- Azure Create VM PowerShell
- Create a free virtual machine in the Azure
- How to create a free virtual machine in the Azure
- Virtual machine in azure
- How to create an Azure virtual machine by using PowerShell
- How To Create Free Virtual Machine In Azure
- Azure Create VM PowerShell
- How To Create A Virtual Machine Using Azure CLI
- How To Create Linux VM In Azure
- How To Create Virtual Machine In Azure Step By Step
- Create Linux VM Using Azure CLI
- Command To Create Virtual Machine In Azure
- az vm create
Hope you have enjoyed this article !!!