This blog post will show you how to create a virtual network and subnet on Microsoft Azure using PowerShell.
Azure Virtual Networks (VNET) is important to any Azure security best practices. The VNET infrastructure can support any deployment topology, meet evolving application business needs, and offer scalability at the data centre level. This also includes the ability to monitor, control, and optimize costs across all networks available in Azure.
The most common topologies that are supported by Azure Virtual Networks (VNETs) include having multiple cloud services in a single VNET, hosting virtual machines across different host servers, and distributing network traffic among data centres.
Virtual networks are the foremost component in Azure unified networking. They provide network isolation, traffic monitoring and control using both security groups and network security groups (NSG), as well as basic connectivity management, bandwidth throttling for data transfer between virtual machines (VMs), VM-to-VM connection configurations, endpoint services to create VPNs or ExpressRoute connections.
Az PowerShell Module
To create a VNET using PowerShell, we use the Az PowerShell module, which runs on any platform.
In our case, we will first create a resource group. You can skip this step and fill in your resource group details in the next cmdlets if you have one.
New-AzResourceGroup -Name vnetlab -Location westus
Before creating the VNET, we need to create a subnet and store it in memory. The subnet will not be created in Azure yet.
$appssubnet = New-AzVirtualNetworkSubnetConfig -Name servers -AddressPrefix "172.16.1.0/24"
The below cmdlet will create a VNET and add the above subnet to it.
New-AzVirtualNetwork -Name MyVNET -ResourceGroupName vnetlab -Location westus-AddressPrefix "172.16.0.0/16" -Subnet $appssubnet
The process to create a VNET in Azure using PowerShell happens in reverse order as we first create the subnet in memory and after creating the actual subnet.
Leave a Reply