Creating VNet Using PowerShell Cmdlets


In this article, I will explain about creating a Virtual Network using Windows PowerShell cmdlets. Before creating a virtual network, let's take a look at the virtual network. The virtual network is like having our own network in a cloud computing environment and with that, we can control security policies, DNS configurations. The IaaS and PaaS in Azure are deployed into subnets using virtual networks and so we can expand the network to Azure with our own IP address configuration. The virtual network can be created by using the Classic portal or through PowerShell cmdlets.


  • An active Azure subscription.
  • Windows PowerShell.

Steps for creating a virtual network using PowerShell cmdlets

The commands are just for reference, you can create VNet in Azure using the commands & replace your own resource names in double quotations of the PowerShell commands, and from this article, the commands with the outputs will be explained in images.

Step 1

Run Windows PowerShell as administrator.

Step 2

I have provided the commands for creating the Data Lake Store in Azure. Open Windows PowerShell and enter the following command.



Step 3

You will be redirected to the Azure portal for sign-in process. Enter your login id and password.

Azure Portal

Step 4

Now, after logging into the account, we need to create a resource group using the PowerShell cmdlet.

New-AzureRmResourceGroup -Name "Name" -Location "Location"


Step 5

After creating a resource group, now we need to create VNet using the PowerShell command.

New-AzureRmVirtualNetwork -ResourceGroupName "Name" -Name TestVNet `

-AddressPrefix -Location "Location"


Step 6

The virtual network object must be stored in the variable using the following command.

$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName "Name" -Name TestVNet


Step 7

Now, we need to add a subnet to Vnet variable for Front-end using the command.

Add-AzureRmVirtualNetworkSubnetConfig -Name FrontEnd `

-VirtualNetwork $vnet -AddressPrefix


Step 8

We need to create a Back-end for subnet using -

Add-AzureRmVirtualNetworkSubnetConfig -Name BackEnd `

-VirtualNetwork $vnet -AddressPrefix


Step 9

Thus, we have created the subnets and they will be in the local variable for retrieving the Vnet. For making the changes, use the following command.

Set-AzureRmVirtualNetwork -VirtualNetwork $vnet


Thus, we have created a virtual network using the PowerShell commands. In the next article, I will explain about linking Virtual Network with Virtual Machine. Thanks for reading!