Loading, please wait...

A to Z Full Forms and Acronyms

Essentials to create a Virtual Machine using Powershell on Azure

Feb 17, 2020 Azure, Powershell, Virtual Machine, 4585 Views
Essentials to create a Virtual Machine using Powershell on Azure

Essentials to create a Virtual Machine using Powershell on Azure

There are various options/parameters which would be used while creating a Virtual Machine either by using Azure Portal or by using Powershell AZ module


  • Powershell 6+
  • Az Module

In this section, we’ll discuss the following parameters:

  1. Resource Group Name
    • It is a kind of virtual container. Each resource in Azure should be aligned to a Resource Group
  2. Virtual Machine Name
    • That is the user’s choice. You can keep any name of your virtual machine.
  3. Location
    • In which location do you want to spin-up your virtual machine. Azure has various regions across the globe. It is advised to read about latency and available services in azure regions beforehand.
  4. Virtual Network Name
    • You can either create a new virtual network or assign the existing one to your virtual machine
  5. Subnet Name
    • The subnet is an integral part of a virtual network. You can either create a new subnet or assign the existing subnet to your virtual machine
  6. Security Group Name
    • Network Security Group is also known as Firewall. It protects from direct access to your virtual machine. It could be directly assigned to a virtual machine or the subnet. That is a design choice.
  7. Public IP Address Name
    • It is the address through which this machine could be accessed
  8. Open Ports
    • If you want various options to allow your virtual machine to be accessed like HTTP, HTTPS, RDP etc.
    • Port 80 is for HTTP, Port 443 is for https (secure connection), Port 3389 for RDP access.

Create a VM using Powershell:

Ensure you have 6.0.0 or above Powershell version installed and AZ module installed before running the command on Powershell

C:\> New-AzVM -ResourceGroupName “azrgdemo” -Name “azvmdemomachine” -Location “EastUS” -VirtualNetworkName “azvnetdemo” -SubnetName “default” -SecurityGroupName “azdemoNSG” -PublicIpAddressName “azdemoipaddr” -OpenPorts 80,3389,443

Though there are a couple of other optional parameters that you could also pass in the command like Tags I have skipped at this moment.

When you run the above command, the Powershell will ask for the credentials


User: abhishekmaitrey

Password for user abhishekmaitrey: **********

Now, the Powershell AZ module will execute this command and start the VM creation process. This activity may take some time. Once the command executed successfully, you will be notified with some detailed information on a new virtual machine like

Virtual Machine Id – It is generally a hashed value like GUID

Fully Qualified Domain Name

A to Z Full Forms and Acronyms