Az.Network PowerShell Module
The Az.Network module provides cmdlets to manage Azure networking resources such as virtual networks, subnets, public IP addresses, load balancers, Application Gateway, and more.
Installation
Install the module from the PowerShell Gallery:
Install-Module -Name Az.Network -Repository PSGallery -Force
Import the module into your session:
Import-Module Az.Network
Getting Started
Connect to your Azure account before running any networking cmdlets:
Connect-AzAccount
Example: Create a new virtual network with a subnet:
# Create a resource group New-AzResourceGroup -Name MyResourceGroup -Location eastus # Create a virtual network $vnet = New-AzVirtualNetwork -Name MyVNet -ResourceGroupName MyResourceGroup -Location eastus -AddressPrefix 10.0.0.0/16 # Add a subnet Add-AzVirtualNetworkSubnetConfig -Name MySubnet -AddressPrefix 10.0.1.0/24 -VirtualNetwork $vnet # Apply changes $vnet | Set-AzVirtualNetwork
Cmdlet Reference
| Cmdlet | Description | 
|---|---|
| New-AzVirtualNetwork | Create a new virtual network. | 
| Remove-AzVirtualNetwork | Delete an existing virtual network. | 
| Get-AzVirtualNetwork | Retrieve virtual network details. | 
| Set-AzVirtualNetwork | Update properties of a virtual network. | 
| New-AzPublicIpAddress | Create a public IP address resource. | 
| New-AzLoadBalancer | Create a load balancer. | 
| Set-AzNetworkInterface | Configure a network interface. | 
| New-AzApplicationGateway | Create an Application Gateway. | 
| Get-AzNetworkWatcher | Retrieve Network Watcher details. | 
| Start-AzNetworkWatcherDiagnostic | Run diagnostic on network resources. | 
For a full list of cmdlets, see the Az.Network Cmdlet Index.
Examples
                Example 1 – Create a Public IP Address
                
            $pip = New-AzPublicIpAddress -Name MyPublicIP -ResourceGroupName MyResourceGroup -Location eastus -AllocationMethod Dynamic Write-Output $pip.IpAddress
                Example 2 – Configure a Load Balancer Backend Pool
                
            # Create backend pool $backendPool = New-AzLoadBalancerBackendAddressPoolConfig -Name MyBackendPool # Create load balancer with backend pool $lb = New-AzLoadBalancer -ResourceGroupName MyResourceGroup -Name MyLoadBalancer -Location eastus -FrontendIpConfiguration $frontendConfig -BackendAddressPool $backendPool
More examples are available in the Az.Network Examples Gallery.