MSDN Tutorials

Azure Virtual Networks

What is an Azure Virtual Network?

Azure Virtual Network (VNet) is the fundamental building block for private networking in Azure. It enables secure communication between Azure resources, on‑premises environments, and the internet.

Virtual Network Subnet A Another VNet Subnet B Peering

Create a Virtual Network

Use the Azure portal, CLI, or PowerShell to create a VNet. Below is a sample Azure CLI command:

az network vnet create \
  --resource-group MyResourceGroup \
  --name MyVNet \
  --address-prefix 10.0.0.0/16 \
  --subnet-name FrontEnd \
  --subnet-prefix 10.0.1.0/24

Define Subnets

Subnets segment the address space within a VNet. Each subnet can have its own network security group (NSG) and route table.

az network vnet subnet create \
  --resource-group MyResourceGroup \
  --vnet-name MyVNet \
  --name BackEnd \
  --address-prefix 10.0.2.0/24

VNet Peering

Peering connects two VNets, allowing resources to communicate across them as if they were in the same network.

az network vnet peering create \
  --name PeerAB \
  --resource-group MyResourceGroup \
  --vnet-name MyVNet \
  --remote-vnet RemoteVNet \
  --allow-vnet-access

Network Security Groups

An NSG contains inbound and outbound security rules that define traffic flow.

az network nsg create \
  --resource-group MyResourceGroup \
  --name MyNSG

FAQ

  • Can I have multiple VNets in a subscription? Yes, you can create as many VNets as needed, subject to subscription limits.
  • Is VNet peering transitive? No. Peering is not transitive; you must configure peering between each pair of VNets.
  • Can I connect a VNet to on‑premises? Yes, using VPN Gateway or Azure ExpressRoute.