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

CmdletDescription
New-AzVirtualNetworkCreate a new virtual network.
Remove-AzVirtualNetworkDelete an existing virtual network.
Get-AzVirtualNetworkRetrieve virtual network details.
Set-AzVirtualNetworkUpdate properties of a virtual network.
New-AzPublicIpAddressCreate a public IP address resource.
New-AzLoadBalancerCreate a load balancer.
Set-AzNetworkInterfaceConfigure a network interface.
New-AzApplicationGatewayCreate an Application Gateway.
Get-AzNetworkWatcherRetrieve Network Watcher details.
Start-AzNetworkWatcherDiagnosticRun 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.

Additional Resources