Introduction
This article will help you to understand what Virtual Network is in Azure and how to create VNet in Azure, using Powershell.
Virtual Network
Microsoft’s Azure Virtual Network in short names such as VNet is a networking mode in Cloud. It’s a representation of a network that we have in Cloud. It helps to provision your Data Center, Azure network settings, DNS settings, routing and other DHCP address blocks. It also helps you to extend your own network to Azure, using IP address blocks.
Note
Read in detail about Azure VNet over here.
You can create VNet in Azure in two ways, using Azure portal or by PowerShell.
Technical Requirements
- Microsoft Azure account – Click here to get a free temporary Azure account.
- Windows PowerShell for Windows 10 – Click here to download it.
Follow the steps, mentioned below.
Step 1
Run your PowerShell now and login with your Azure account over here, using the command, mentioned below.
Login-AzureRmAccount
Login with your Azure account here.
There goes your account logged in.
Step 2
Now, create a resource group in your Azure account, using the command, mentioned below.
New-AzureRmResourceGroup -Name ________ -Location ___________
Note
In the command, mentioned below, replace the name “______” with the resource group name that you need and location “_________” with the location of Azure Data center that you prefer.
Now, Azure resource group is created with the name that we have mentioned.
Step 3
Lets create a new VNet now with the command, mentioned below.
New-AzureRmVirtualNetwork -ResourceGroupName vnetrg -Name TestVNet `-AddressPrefix 192.168.0.0/16 -Location centralus
You should get a display, as shown above.
Step 4
Let's store the virtual network object in a variable, using the command, mentioned below.
$vnet = Get-AzureRmVirtualNetwork -ResourceGroupName TestRG -Name TestVNet
Step 5
Now, we will be adding a subnet to the VNet variable, using the command, mentioned below.
Add-AzureRmVirtualNetworkSubnetConfig -Name FrontEnd ` -VirtualNetwork $vnet -AddressPrefix 192.168.1.0/24
Step 6
Finally, you can save all the changes that you have done, using the command, mentioned below.
Set-AzureRmVirtualNetwork -VirtualNetwork $vnet
Follow my next article to work on a virtual network by creating a Virtual Machine, which will run a Windows VM, by selecting an existing VNet and subnet to connect a virtual machine.