Preparing AZ-104 : Creating Virtual Network (VNet) from PowerShell and related CMDLETs – Azure Administration

Hi All,
Greetings for the day!!!
We are discussing one of the most important concept of AZURE “Virtual Network”.
Till now we discussed
- Preparing AZ-104 : Understand Virtual Networks (VNet) – Important concept / feature in AZURE – Simplifying concepts
- Preparing AZ-104 : Creating Virtual Networks (VNet) from Azure portal – Important concept / feature in AZURE – Simplifying concepts
Today we will continue our discussion and will create Virtual Network using PowerShell. This will help for administrators as well as for preparing interviews
If you do not have AZURE account, try for free AZURE account. Please have a look at our article – Azure : creating Azure free account
POWERSHELL CMDLET to create Virtual Network (VNet)
- For creating Virtual Network we need resource group. If you new to Resource Group we have very good articles on Resource Groups, please have a look
- Assuming Resource Group is created say – “rg-azure-dev-centralindia-001” as

- New-AzVirtualNetwork cmdlet is used to create new Virtual Network (VNet)
- Syntax
New-AzVirtualNetwork
-Name <String>
-ResourceGroupName <String>
-Location <String>
-AddressPrefix <String[]>
[-DnsServer <String[]>]
[-FlowTimeout <Int32>]
[-Subnet <PSSubnet[]>]
[-BgpCommunity <String>]
[-EnableEncryption <String>]
[-EncryptionEnforcementPolicy <String>]
[-Tag <Hashtable>]
[-EnableDdosProtection]
[-DdosProtectionPlanId <String>]
[-IpAllocation <PSIpAllocation[]>]
[-EdgeZone <String>]
[-Force]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
- Examples
New-AzVirtualNetwork -Name vnet-azure-dev-centralindia-002 -ResourceGroupName rg-azure-dev-centralindia-001 -Location centralindia -AddressPrefix "10.0.0.0/16"
- VNet “vnet-azure-dev-centralindia-002” created successfully 🙂
- On VNet listing page if we click on VNet “vnet-azure-dev-centralindia-002”, we will see the details as shown in below figure
Other VNet PowerShell CMDLETs
- Get all Virtual Networks – Get-AzVirtualNetwork
Get-AzVirtualNetwork
[-Name <String>]
[-ResourceGroupName <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzVirtualNetwork | Format-Table Name, ResourceGroupName, Location
- Delete Virtual Network – Remove-AzVirtualNetwork
Remove-AzVirtualNetwork
-Name <String>
-ResourceGroupName <String>
[-Force]
[-PassThru]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
- “Remove-AzVirtualNetwork“ will prompt us once for removing as shown in above figure
- On click of “Yes” respective Virtual Network will be removed
- If we again execute “Get-AzVirtualNetwork” CMDLET we will see only one virtual network listed

Thanks for reading. If its worth reading, kindly please share and like. For more azure articles kindly subscribe 🙂
HAVE A WONDERFUL n PEACEFUL TIME AHEAD 🙂
You must be logged in to post a comment.