Virtual Network (VNet) in Azure

Virtual Network (VNet) in Azure

A friendly, deep walk through the private network that sits underneath almost everything you build in Azure: how it is planned, divided, connected, secured, watched, and paid for.

Imagine you are building a new office campus. Before anyone moves in, you must decide where the walls go, how many buildings there are, which doors are locked, which gates face the street, and how the campus connects to the head office in another city. Nobody would start hiring staff and buying desks before drawing that plan, because changing the walls later is expensive and disruptive.

In the cloud, the same plan is called a virtual network. Every server, database, and container you run in Azure needs a place to live and a way to talk to other things. The virtual network is that place. It is your own private, walled-off neighborhood inside Azure, where you decide the street names, the gates, and the guards.

In this guide you will learn what a virtual network is, how addresses and subnets work, how traffic finds its way, how to connect networks together and to your office, how to keep everything safe, and how to avoid the mistakes that catch most beginners. No earlier networking knowledge is required, and every new word is explained as it appears.

1What Is an Azure Virtual Network?

An Azure Virtual Network, shortened to VNet, is your own private, isolated network inside Azure, where your cloud resources can talk to each other, to the internet, and to your own offices under rules that you control.

First, what is a network?

A network is a group of computers that can send messages to each other. Each computer has an address, which works like a house number, so that messages reach the right place. Special devices such as switches and routers pass the messages along, and rules decide who is allowed to talk to whom. In an office, a network technician plugs in cables and configures these devices. In the cloud, there are no cables for you to touch. Everything is created with software.

What a virtual network is

A virtual network is a software version of the network you would build in a data center. Azure creates it for you, and it is logically isolated from every other customer’s network, even though it runs on shared physical hardware. Inside your VNet, you choose the range of addresses, divide it into smaller sections called subnets, and place resources such as virtual machines, databases, and containers into those sections. Resources in the same VNet can talk to each other privately by default.

Analogy

Think of a large apartment complex with its own boundary wall and its own street map. Families inside can visit each other freely, but outsiders cannot walk in unless the gate allows them. The complex belongs to you alone, even though it stands on land that is part of a huge city. The wall is the isolation, the street map is the address plan, and the gates are the connections to the outside world.

What a VNet gives you

  • Isolation. Your network is private. Nobody else can see into it unless you allow it.
  • Private communication. Resources inside the VNet talk to each other over private addresses.
  • Segmentation. You can divide the network into subnets, such as web, application, and database areas, and control traffic between them.
  • Connectivity. You can connect to the internet, to other VNets, and to your own offices or data centers.
  • Filtering and routing. You decide which traffic is allowed and which path it takes.
  • Integration. Many Azure services, such as virtual machines, scale sets, Kubernetes, and databases, plug into a VNet.
$0
cost for the virtual network itself. You pay for the resources and gateways you add to it
1
region per VNet, and one subscription. A VNet never stretches across two regions
5
addresses Azure keeps in every subnet for its own use
i
Remember this

The VNet is the foundation. It is free, but almost every mistake in it, such as overlapping address ranges or tiny subnets, is expensive to repair later. A little planning on day one saves months of pain.

2Why Virtual Networks Exist

To see why VNets matter, picture what the cloud would be like without them.

The problem of the open street

If every cloud server sat directly on the public internet, anyone in the world could try to connect to it. Databases that should speak only to a few trusted programs would be reachable by strangers. Companies would have to guard every single machine against attacks. This is like building every house in a city on the main road with no walls and no gates.

The problem of tangled traffic

Large systems have many parts that must talk to each other: web servers, application servers, queues, caches, and databases. If all of them share one flat space, one weak machine can be used to attack the others. Teams need a way to put walls inside the system, so that a problem in one part cannot easily spread to the rest.

The problem of connecting to the old world

Most companies already have offices and data centers with their own networks and their own addressing plans. When they move to the cloud, they do not move everything on the same day. For months or years, the old and the new must work together. They need a private, controlled bridge between them, and that bridge needs a network on the cloud side that they can plan like their own.

Analogy

A hospital does not place its operating theatre next to the main entrance. It has a reception area anyone can enter, a ward that only patients and visitors can reach, and an operating area that only authorized staff can enter. Walls and doors between the areas are the point. A virtual network lets you build the same kind of zones for your systems.

What the VNet solves

Private homes for sensitive systems

Databases and internal services can have only private addresses, so they are invisible from the internet but still reachable by your applications.

Zones inside one system

Web, application, and data tiers sit in separate subnets with rules between them, so each tier can talk only to the tiers it truly needs.

A bridge to your offices

A VPN or a private circuit connects your on-premises network to the VNet, so staff and applications can reach cloud resources as if they were on the same network.

Order across many teams

Large companies use many VNets, one per application or environment, connected in a planned pattern, so each team has its own space within shared rules.

Build the walls before the people move in.

3Core Concepts and Vocabulary

Networking has its own small language. Learn these words once, and the rest of this guide and the Azure documentation will read easily.

The network

Virtual network (VNet)

Your private network in one Azure region and one subscription. It holds your address space and subnets.

Address range

Address space

The overall block of private addresses given to a VNet, written in a short style such as 10.0.0.0/16.

Section

Subnet

A smaller slice of the address space. Resources are placed in subnets, which are the basic unit for applying rules.

Notation

CIDR

A compact way of writing an address range. The number after the slash says how big the range is.

Door

Network interface (NIC)

The virtual network card that connects a virtual machine to a subnet and gives it a private address.

Guard

Network security group (NSG)

A list of allow and deny rules that filters traffic going into and out of subnets or network interfaces.

Signpost

Route table

A list of directions that tells traffic which path to take to reach a destination.

Link

Peering

A private connection between two VNets, so resources in each can talk as if they were in one network.

Bridge

VPN gateway

A service that creates encrypted tunnels over the internet between your VNet and other networks.

Private road

ExpressRoute

A private line from your office or data center into Azure that does not travel over the public internet.

Phone book

DNS

The Domain Name System, which turns names such as shop.internal into addresses that computers use.

Private door

Private endpoint

A private address inside your subnet that connects to an Azure service, such as storage or a database, over a private path.

Outbound

NAT Gateway

A service that lets many private resources reach the internet using one or a few stable public addresses, while blocking unsolicited inbound connections.

Public address

Public IP address

An address reachable from the internet. Resources only need one if they must be reached directly from outside.

Label

Service tag

A named group of addresses maintained by Azure, such as Storage or Internet, used in rules instead of long address lists.

Inspector

Network Watcher

A toolbox for testing, diagnosing, and recording what happens in your Azure network.

Private and public addresses

Addresses come in two families. Public addresses are unique across the whole internet and are used to be found from outside. Private addresses are used only inside networks, and many different networks can use the same ones at the same time without any conflict. Three ranges are reserved for private use: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. Almost every VNet is built from these ranges.

Analogy

Public addresses are like full postal addresses including city and country, and they are unique in the world. Private addresses are like flat numbers inside a housing society. “Flat 204” exists in thousands of societies, and there is no confusion because each society is separate. Trouble starts only when two societies want to share one mailroom, and both have a Flat 204.

Stateful filtering

The rules in a network security group are stateful. If you allow a request to go out, Azure automatically allows the reply to come back. You do not need a second rule for the return trip. This keeps rule lists short and easy to read.

4Architecture and Components

A virtual network is rarely alone. It sits in the middle of a small city of services that bring traffic in, send traffic out, connect it to other places, and keep it safe.

flowchart TD
    USERS["Users on the Internet"] --> AGW
    subgraph VNET["Virtual Network 10.0.0.0/16"]
        AGW["Application Gateway with firewall in its own subnet"]
        subgraph WEB["Web subnet 10.0.1.0/24"]
            W1["Web VM 1"]
            W2["Web VM 2"]
        end
        subgraph APPS["App subnet 10.0.2.0/24"]
            A1["Application VM"]
        end
        subgraph DATA["Data subnet 10.0.3.0/24"]
            PE["Private endpoint to the database"]
        end
        GW["GatewaySubnet 10.0.255.0/27 for VPN or ExpressRoute"]
    end
    AGW --> W1
    AGW --> W2
    W1 --> A1
    W2 --> A1
    A1 --> PE
    NSG["Network security groups on each subnet"] -.-> VNET
    W1 -.-> NAT["NAT Gateway for outbound traffic"]
    NAT --> OUT["Internet destinations"]
    ONP["On premises network"] -->|"VPN or ExpressRoute"| GW
    VNET |"VNet peering"| PEER["Peered VNet in another region or subscription"]
    
Figure 1: A typical virtual network with three tiers, a gateway, outbound access, and a peered network

Read the diagram from the top. Users reach an application gateway, which sits in its own subnet and passes allowed requests to the web servers. The web servers talk to an application server in the next subnet, which reaches the database through a private endpoint in the data subnet. Network security groups filter the traffic at each step. Outbound requests to the internet go through a NAT gateway so that they leave from a stable address. Your on-premises network joins through the gateway subnet, and another VNet joins through peering.

The address and subnet layer

This is the skeleton. The address space gives the VNet its range, and subnets divide it. Every other component attaches to a subnet.

The filtering layer

Network security groups and, for deeper inspection, services such as Azure Firewall and web application firewalls decide which traffic is allowed. They are the guards at the gates and doors.

The routing layer

Azure creates default routes automatically. You can override them with route tables, for example to send all outbound traffic through a firewall. Routing decides which path a packet takes.

The connection layer

Peering, VPN gateways, ExpressRoute, and Virtual WAN join your VNet to other networks. They are the bridges and roads leading out of the neighborhood.

The name layer

DNS turns names into addresses. Azure provides DNS by default, and private DNS zones let you create your own internal names.

The management layer

Everything is created through Azure Resource Manager and can be managed with the portal, command line, or templates. Network Watcher and Azure Monitor provide visibility.

Analogy

Picture a company campus. The boundary wall is the VNet. Each building is a subnet. The security desks at each building are the network security groups. The road signs are the route tables. The main gate to the city is the NAT gateway and the load balancer. The private tunnel to the head office is the VPN or ExpressRoute. The campus phone directory is DNS.

5Address Spaces and CIDR

The address space is the single most important planning decision in a VNet. Once other things depend on it, it is hard to change.

Reading a CIDR range

An address range is written like 10.0.0.0/16. The first part is the starting address. The number after the slash tells you how many addresses the range holds. A smaller number after the slash means a bigger range. You do not need to calculate in your head. A few sizes cover most of what you will use.

Range sizeTotal addressesUsable in an Azure subnetTypical use
/1665,536Not a subnet size you usually use; a whole VNetA full VNet address space
/24256251A normal application subnet
/266459Firewall or Bastion subnet
/273227Gateway subnet for a VPN or ExpressRoute gateway
/281611Small services and delegated subnets with few instances
/2983The smallest subnet Azure allows

Why usable is less than total

Azure keeps five addresses in every subnet for its own purposes: the first address names the network, the next is the default gateway, two more are used for Azure’s internal DNS mapping, and the last is the broadcast address. A /29 subnet with eight addresses therefore has only three left for your use. This catches many beginners who size subnets too tightly.

Analogy

Think of a block of eight flats where five are kept by the building: one for the watchman, one for the electricity room, two for the mail and notice systems, and one for the maintenance office. Only three are left for families. Small blocks lose a big share to the building itself.

Choosing the private ranges

The three private ranges differ in size. The 10.0.0.0/8 range is huge, with over sixteen million addresses, and is the favorite for large companies. The 172.16.0.0/12 range holds about a million. The 192.168.0.0/16 range holds about sixty-five thousand and is common in home and small office networks. Azure also lets you use other ranges, but you should stay inside the private ones to avoid clashes with real internet addresses.

Addresses Azure does not allow

A few ranges cannot be used in a VNet because they have special meaning: multicast, broadcast, loopback, link-local, and the address Azure uses for its own internal DNS and health services. You will see an error if you try.

The golden rule: no overlaps

Two networks that must be connected cannot have overlapping address ranges. If your office uses 10.0.0.0/16 and your VNet also uses 10.0.0.0/16, a computer cannot tell which network a message is meant for. The same rule applies between VNets that you wish to peer and between VNets and the on-premises networks they connect to. The cheapest way to avoid this is to plan a single address map for the whole company, before building anything.

1

Collect what exists

List every address range already used in offices, data centers, partner connections, and other clouds.

2

Reserve a large block for Azure

Choose a big, unused block, for example a /12 or /14 from the 10.0.0.0/8 space, and set it aside for all current and future Azure networks.

3

Give each VNet a slice

Hand out ranges, such as one /16 per application or environment, and record them in a shared register.

4

Divide each VNet into subnets with spare room

Size subnets for growth, and leave some of the address space unassigned for future needs.

!
Costly mistake

Using the default range for every project because “it is only a test” is one of the most common causes of later pain. The test becomes production, and then nobody can peer or connect the networks without painful renumbering.

6Subnets and Special Subnets

Subnets are where your resources actually live. Good subnet design makes security, growth, and troubleshooting much easier.

Why divide into subnets?

  • Security zones. Different tiers get different rules. The data subnet can refuse everything except the application subnet.
  • Organization. Resources with similar roles sit together, so you can find and manage them easily.
  • Service requirements. Some Azure services need their own dedicated subnet.
  • Routing control. A route table or NAT gateway can be attached to a subnet, affecting everything inside.

Special subnets with special rules

Several Azure services require a subnet of their own, sometimes with a required name or minimum size. Always check the current documentation, because requirements can change.

SubnetUsed forNotes
GatewaySubnetVPN gateways and ExpressRoute gatewaysMust have exactly this name. A /27 or larger is recommended so it can grow
AzureFirewallSubnetAzure FirewallMust have exactly this name, with at least a /26
AzureBastionSubnetAzure Bastion, for safe remote access to VMsMust have exactly this name, with at least a /26
Application Gateway subnetApplication GatewayA dedicated subnet; a /24 is commonly advised for growth
Delegated subnetsServices such as database servers, file storage, and managed instances that place their own network interfaces in your subnetDelegation reserves the subnet for that service type
Private endpoint subnetPrivate connections to Azure servicesOften a shared subnet kept for endpoints only
Analogy

A shopping mall has ordinary shops, but also a service entrance for deliveries, a security control room, and a parking area, each needing its own space with its own rules. Special subnets are those reserved areas of the mall.

A typical layout

Edge

Gateway and firewall subnets

Hold the devices that connect the VNet to other networks and inspect traffic.

Front

Web subnet

Holds servers that receive requests from users or from a load balancer.

Middle

Application subnet

Holds business logic that should be reachable only from the web tier.

Back

Data subnet

Holds databases and private endpoints, reachable only from the application tier.

Admin

Management subnet

Holds tools and Bastion for administrators, tightly restricted.

Platform

Delegated subnets

Hold managed services that need their own network space.

Sizing subnets

Count the resources you expect today, add what you might need in two or three years, and add room for upgrades, because rolling updates can briefly need extra addresses. Remember the five reserved addresses. Some services use many addresses: a Kubernetes cluster that gives every pod its own VNet address can use thousands. Plan generously, since a subnet that holds resources cannot easily be shrunk or moved.

Growing later

You can usually add a new address range to a VNet and create new subnets in it, even while the VNet is in use. Changing a subnet that already contains resources is limited. It is much easier to add new space than to fix cramped space, so keep part of your address range unassigned.

i
Design tip

Treat subnets as security boundaries, not as folders for tidiness. A subnet that mixes public-facing servers and private databases is hard to protect, because every rule must be written around the exceptions.

7How Traffic Flows and Routing Works

Let us follow one message from a virtual machine in one subnet to a virtual machine in another, and see what Azure does at every step.

sequenceDiagram
    participant A as VM A in the Web Subnet
    participant NA as NSG for the Web Subnet
    participant R as Azure Routing
    participant NB as NSG for the App Subnet
    participant B as VM B in the App Subnet
    A->>NA: Send a message to 10.0.2.4 on port 8080
    NA->>NA: Check outbound rules in priority order
    NA->>R: Allowed, pass on to routing
    R->>R: Choose the most specific matching route
    R->>NB: Deliver toward the App subnet
    NB->>NB: Check inbound rules in priority order
    NB->>B: Allowed, deliver the message
    B-->>A: The reply returns because the rules are stateful
    
Figure 2: A message crossing two subnets in the same virtual network

Step by step

1

The sender builds the message

The application on VM A addresses the message to the private address of VM B and a port number that identifies the program on B.

2

Outbound rules are checked

Any network security group attached to VM A’s subnet or network interface is checked. Rules are read from the lowest priority number up, and the first matching rule wins.

3

Routing picks the path

Azure looks up the destination in the route table that applies to the subnet. For traffic inside the VNet, the default route sends it straight to the destination.

4

Inbound rules are checked

At the receiving side, the network security groups on VM B’s subnet and network interface are checked. If they allow the message, it is delivered.

5

The reply returns automatically

Because the rules are stateful, the reply to an allowed request is allowed without a separate rule.

Default routes

Every subnet starts with system routes that Azure creates for you. They allow traffic to move between subnets in the same VNet, to the internet for any address not otherwise known, and, once you set them up, to peered networks and gateway-connected networks. You never see them in a table you wrote, but you can view them as the effective routes of a network interface.

Custom routes

Sometimes you need traffic to take a different path. A common example is sending all internet-bound traffic through a firewall first. You create a route table with a user-defined route and attach it to a subnet. The route says, “For this destination range, send traffic to this next hop.” Next hops can be a virtual appliance such as a firewall, a gateway, the VNet itself, the internet, or “none”, which drops the traffic.

Longest match wins

When several routes could apply, Azure chooses the most specific one, meaning the one with the longest prefix. A route for 10.0.2.0/24 beats a route for 10.0.0.0/16, which beats a route for everything. If prefixes are equal, user-defined routes win over routes learned from gateways, which win over system routes.

Analogy

Imagine asking directions in a city. A signpost that says “Hospital: second left” is more helpful than one that says “City centre: straight ahead”. The driver follows the most specific sign that matches the destination. Azure routing does the same with prefixes.

!
Watch out

A user-defined route that sends traffic to a firewall must be matched by firewall rules and a return path. If the reply comes back by a different route, the firewall never sees the whole conversation and drops it. This problem, called asymmetric routing, is a classic cause of mysterious timeouts.

8Network Security Groups and Application Security Groups

Network security groups are the main traffic filters inside a VNet. Understanding their rules and default behavior prevents most access problems.

What a rule contains

Each rule describes a kind of traffic and what to do with it. It has a name, a priority, a direction (inbound or outbound), a source, a destination, a protocol, a port, and an action: allow or deny. Priorities are numbers between 100 and 4096. A lower number is checked first, and as soon as a rule matches, no further rules are read.

The built-in default rules

DirectionDefault ruleEffect
InboundAllowVnetInBoundTraffic from inside the VNet, including peered and connected networks, is allowed
InboundAllowAzureLoadBalancerInBoundHealth checks from the Azure load balancer are allowed
InboundDenyAllInBoundAll other inbound traffic is blocked
OutboundAllowVnetOutBoundTraffic to the VNet and connected networks is allowed
OutboundAllowInternetOutBoundTraffic to the internet is allowed
OutboundDenyAllOutBoundAll other outbound traffic is blocked

These default rules have very large priority numbers, such as 65000 and above, so your own rules with smaller numbers always come first. The result is a sensible starting point: resources in the VNet can talk freely to each other, outsiders cannot get in, and the outside world is reachable for outbound traffic. Many security teams then add rules to tighten what is allowed inside the VNet too.

Where to attach a group

  • On a subnet to apply the same rules to every resource inside it. This is the usual choice, since it is easy to see and hard to forget.
  • On a network interface for exceptions that apply to one machine.
  • When both exist, the traffic must pass both. For inbound traffic the subnet group is checked first, then the interface group. For outbound traffic the order is reversed.

Service tags and application security groups

Writing rules with long lists of addresses is tiring and fragile. Two features make rules readable. A service tag is a name for a group of addresses that Azure keeps up to date, such as Internet, VirtualNetwork, AzureLoadBalancer, or Storage. An application security group lets you give virtual machines a role name such as “web-servers” or “db-servers”, and then write rules between those names, no matter what addresses the machines have. When a new web server joins the group, the rules apply to it at once.

Analogy

A school gate rule that says “Only students with the blue badge may enter the library” is easier to manage than a list of five hundred student names. When a new student arrives, you give them a blue badge, and the rule already covers them. Application security groups are badges for servers.

A sample rule set for a three-tier system

SubnetInbound allowed fromOutbound allowed to
WebThe application gateway or load balancer on the web portThe application subnet on the application port
ApplicationThe web subnet on the application port onlyThe data subnet on the database port
DataThe application subnet on the database port onlyNothing outside the VNet, except needed platform services
ManagementBastion or a trusted admin rangeManagement ports on the other subnets
i
Good habit

Number your rules in steps of ten or a hundred, and give them clear names that describe their purpose, such as “allow-web-to-app-8080”. When someone reads the list six months later, the reasons will be obvious.

!
Never do this

Do not leave remote administration ports such as 22 for Linux or 3389 for Windows open to the whole internet. Automated attacks find open management ports within minutes. Use Azure Bastion or a tightly restricted address range instead.

9Connecting to the Internet

Most systems need to talk to the internet in two directions: letting users in, and letting servers reach out for updates, payments, and other services. Azure gives you several tools for each direction, and choosing wisely is part of good design.

Outbound: leaving the neighborhood

A virtual machine with only a private address still needs to reach outside services, for example to download a security update or call a payment provider. For this to work, the private address must be swapped for a public one on the way out, and swapped back on the way in. This swap is called source network address translation, or SNAT. It is the same trick your home router uses so that every phone and laptop in your house can share one public address from your internet provider.

Azure offers a few ways to do this outbound swap.

  • A public IP address on the machine. The simplest way, but it also makes the machine reachable from outside unless rules block it. Fine for tests, rarely wise for production.
  • A standard load balancer with outbound rules. Machines behind the load balancer share its public addresses for outbound traffic.
  • A NAT gateway. A dedicated service attached to a subnet. Every machine in the subnet goes out through the gateway’s public addresses. This is the recommended choice for most new designs because it is simple and scales well.
  • A firewall or virtual appliance. Traffic is sent there by a user-defined route, and the device does the translation and the inspection together.
  • Default outbound access. In older setups, machines with no explicit outbound method were given a hidden, unstable public address by Azure. Microsoft has been moving away from this, and new virtual networks are being created without it. Treat it as something you should not depend on, and check the current announcements for the exact dates.
Analogy

Imagine a large company where every employee has an internal extension number, but outside callers see only the company’s main phone number. When an employee calls out, the switchboard shows the main number, and when the reply comes, the switchboard connects it to the right extension. A NAT gateway is that switchboard.

Why the NAT gateway is popular

A NAT gateway gives you a stable set of outbound addresses, which is useful when a partner asks you to add your addresses to an allowed list. It also blocks connections that start from the internet, because it only handles traffic that began inside. It works at the subnet level, so you attach it once and everything in that subnet benefits. You can give it one public address or several, or a block of addresses.

Port exhaustion

Each public address can keep only about sixty-four thousand simultaneous connections to the same outside destination, because each connection needs its own port number. A busy application that opens many short connections to one service can run out of ports, and new connections then fail in strange, random ways. The fixes are to add more public addresses to the gateway, to reuse connections instead of opening new ones, and to use private endpoints for Azure services so the traffic does not need translation at all.

Inbound: letting visitors in

For inbound traffic from the internet, you do not normally put a public address on every machine. Instead, you put a public entry point in front of them.

Layer 4

Azure Load Balancer

Spreads connections across healthy machines using addresses and ports. Fast and simple, and it does not read web content.

Layer 7

Application Gateway

Understands web requests. It can route by URL path or host name, end secure connections, and run a web application firewall.

Global

Front Door

A worldwide entry point that routes users to the nearest healthy region and can cache content and filter attacks.

Inspect

Azure Firewall

Can publish internal services to the internet through destination translation rules, with full inspection.

Public IP addresses

A public IP address is a separate Azure resource that you attach to a load balancer, gateway, firewall, or machine. Current designs use the Standard type, which is secure by default: it blocks all inbound traffic until a network security group explicitly allows it, and it supports availability zones. The older Basic type has been announced for retirement, so avoid it for new work and confirm the dates in current documentation.

i
Simple rule of thumb

Put public addresses only on the front doors: gateways, load balancers, and firewalls. Everything behind them gets private addresses only. This single habit removes a large share of common security problems.

10The Life of a VNet and Its Data

A virtual network is not built once and forgotten. It moves through stages, from a planning sketch to a living, changing system, and finally to retirement. Knowing the stages helps you decide what to do when.

flowchart LR
    P["Plan the address map"] --> C["Create the VNet and subnets"]
    C --> S["Attach security groups and route tables"]
    S --> D["Deploy resources into subnets"]
    D --> L["Link to other networks by peering, VPN, or ExpressRoute"]
    L --> M["Monitor traffic and health"]
    M --> G["Grow, tighten rules, and clean up"]
    G --> M
    G --> R["Retire unused parts"]
    
Figure 3: The life of a virtual network, from planning to retirement

The diagram shows a loop in the middle. After you deploy and connect things, you keep watching and adjusting. Growth and tightening happen again and again, and only at the very end do you retire parts that nobody uses.

Stage one: plan

Draw the address map, decide how many VNets you need, and decide how they will connect. Agree who owns each range. This is paper work, and it is the cheapest stage to make mistakes in.

Stage two: create

Build the VNet and its subnets using a template or code rather than clicking in the portal. Code can be reviewed, repeated, and stored. A network built by hand tends to drift away from what anyone remembers.

Stage three: protect

Attach network security groups and route tables before the first workload arrives, not after. A subnet that begins life with sensible rules never has a moment of being wide open.

Stage four: deploy and connect

Resources are placed in subnets and, if needed, the VNet is joined to others. Each new connection changes who can reach what, so rules should be reviewed whenever a connection is added.

Stage five: observe and adjust

This is the longest stage. You watch flow records, check for blocked traffic, review costs, and respond to changing needs. Address space is added, subnets are created, and unused rules are removed.

Stage six: retire

Delete what is no longer needed: old subnets, unattached public addresses, unused gateways, and forgotten peerings. Leftover pieces cost money and create risk, because nobody remembers what they are for.

Analogy

A city’s road network follows the same cycle. Planners lay out the map, builders pave the roads, officials set speed limits and signals, and people start to use them. Traffic is counted, bottlenecks are widened, and abandoned side roads are closed. A good network is never finished; it is kept healthy.

What happens to data in transit

Traffic between resources inside a VNet travels on Microsoft’s network and does not cross the public internet. Even so, you should treat the network as something that can fail or be misused, and encrypt sensitive data with TLS between your own services. Traffic that crosses between datacenters on Microsoft’s backbone is typically protected by the platform, but you should check current documentation on exactly what is encrypted by default, since the details differ between features.

Data does not “live” in a VNet. A VNet stores no application data of its own. It only carries traffic. What it does keep is configuration: ranges, rules, routes, and connections. That configuration is what you protect and back up as code.

11VNet Peering and Network Topologies

One VNet is rarely enough. Companies run many applications, many environments, and many regions. Peering joins separate VNets so they can talk privately.

What peering is

Peering creates a direct, private link between two VNets. Once connected, resources in each can reach those in the other using private addresses, as if they were in the same network. The traffic travels over Microsoft’s backbone, not the public internet, and it has low delay and high speed. Peering works between VNets in the same region and across regions, which is called global peering. It can also join VNets in different subscriptions and even in different Microsoft Entra tenants, with proper permissions.

Analogy

Two neighboring housing societies build a gate in the wall between them. Residents of either society can walk through to visit the other, and the gate is private, so outsiders cannot use it. Each society still keeps its own wall, guards, and rules.

Rules you must know

  • No overlapping address space. Peered VNets must have different ranges.
  • Peering is non-transitive. If A is peered with B, and B is peered with C, A cannot reach C through B. You must peer A with C directly or use a central device to route between them.
  • Peering works in both directions only when both sides are set up. Each VNet needs its own link pointing at the other.
  • Network security groups still apply. Peering does not remove your filters. The default rules treat the peered network as part of the virtual network, so you may need extra rules to restrict it.
  • You pay for data that crosses a peering. Charges are per gigabyte, and they are higher for global peering. Check current prices.
  • Limits exist. Each VNet can have a maximum number of peerings, so very large designs need a different approach. Confirm the current limit.

Gateway transit

If one VNet has a VPN or ExpressRoute gateway, other peered VNets can use it to reach your offices, instead of each building its own expensive gateway. The VNet with the gateway enables allow gateway transit, and the other enables use remote gateways. This is the heart of the most popular design pattern.

Hub-and-spoke

In a hub-and-spoke design, one central VNet, the hub, holds shared services such as the gateway, firewall, DNS, and management tools. Many spoke VNets, each for an application or team, are peered to the hub. Traffic between spokes is sent through the hub’s firewall using user-defined routes, so it is inspected and logged. This gives order, shared cost, and a single place to enforce rules.

TopologyHow it looksStrengthWeakness
Single VNetEverything in one network with several subnetsSimplest; fine for small systemsHard to separate teams; limits and blast radius grow
Full meshEvery VNet peered with every otherDirect, fast paths between any twoNumber of links grows quickly; messy to manage
Hub and spokeShared hub, many spokesCentral control, shared gateway and firewallHub can become a bottleneck or single point of failure if not designed well
Managed hub, such as Virtual WANMicrosoft-run hubs that connect branches and VNetsLess to build and run yourselfLess low-level control; different pricing model

Tools that help at scale

Azure Virtual Network Manager lets you group many VNets and apply connectivity and security rules to the whole group at once, instead of configuring each peering by hand. Azure Virtual WAN offers a Microsoft-managed network backbone with hubs that handle branches, VPNs, ExpressRoute, and VNet connections. Both are worth a look when you manage dozens of networks. The exact features and pricing change over time, so confirm them in current documentation.

!
Trap

Teams often assume that because the hub is peered to every spoke, every spoke can reach every other. It cannot, because peering is not transitive. Without a firewall or router in the hub and routes pointing at it, the spokes remain isolated from each other.

12Hybrid Connectivity: VPN Gateway and ExpressRoute

Many companies keep part of their systems in their own offices or data centers. Hybrid connectivity joins those networks to the VNet so the two feel like one.

Site-to-site VPN

A VPN gateway is a service that sits in the gateway subnet and builds an encrypted tunnel across the public internet to a VPN device in your office. Everything that goes through the tunnel is scrambled, so even though the road is public, the content is private. It is quick to set up, relatively inexpensive, and good for smaller needs, backups, and as a standby path. Speed depends on the gateway size you pick, and internet quality affects delay and reliability.

Gateways come in several sizes, called SKUs. Larger ones give more throughput and more tunnels, and some can span availability zones. Names and limits change from time to time, so check current documentation before choosing.

Point-to-site VPN

A point-to-site connection lets a single laptop connect securely to the VNet from anywhere, for example a developer working from home. It uses the same gateway and signs the user in with certificates, Microsoft Entra ID, or similar means.

ExpressRoute

ExpressRoute is a private line between your premises and Microsoft, set up with a connectivity provider. It does not use the public internet, so it offers steadier delay, higher speeds, and a different security profile. It is often chosen for large data transfers, strict business needs, and systems that cannot tolerate internet unpredictability. It costs more and takes longer to arrange, because a physical circuit is involved.

Analogy

A VPN is like sending your goods in a locked box through the public highway. It is safe because of the lock, but you share the road with everyone, so traffic jams happen. ExpressRoute is like a private road built from your factory to the port. It is more expensive to build, but it is faster, more predictable, and shared with nobody.

VPN gateway: strengths

  • Fast to create, often in under an hour of setup work
  • Lower cost
  • Encrypted by design
  • Works anywhere with internet

VPN gateway: limits

  • Speed and delay depend on the internet
  • Throughput capped by gateway size
  • Not ideal for very large or very sensitive flows
  • Gateways take a while to create or resize

ExpressRoute: strengths

  • Private path, not on the public internet
  • Predictable performance
  • High bandwidth options
  • Good fit for regulated and heavy workloads

ExpressRoute: limits

  • Higher cost, including provider fees
  • Lead time for circuits
  • Not encrypted by itself unless you add encryption
  • Needs careful planning for redundancy

Using both together

Many companies run ExpressRoute as the main path and a VPN as a backup. If the private line fails, traffic flows over the VPN. This combination needs careful routing so that traffic prefers the better path under normal conditions.

Routing between networks

Gateways can learn routes dynamically using a protocol called BGP, the Border Gateway Protocol. With BGP, your office and Azure tell each other which address ranges they hold, so new networks are discovered automatically. Without it, someone must update the lists by hand. BGP is strongly recommended for anything beyond a very small setup.

i
Plan the gateway subnet early

The gateway subnet must be created with enough room, and it must be named exactly GatewaySubnet. Making it too small now can force you to rebuild the gateway later when you want a bigger size or a second gateway for resilience.

13DNS and Name Resolution

People remember names; computers need addresses. DNS is the service that connects the two, and when it breaks, everything seems broken even though the network is fine.

The default behavior

Every VNet comes with a built-in name service provided by Azure. It lives at the special address 168.63.129.16, which is reachable from inside every VNet. Virtual machines in the same VNet can find each other by name without extra setup. For many small systems this is enough.

Analogy

DNS is the phone book of the network. You look up “Rahul Sharma” and the book gives you a number. If the book is out of date, or you are reading the wrong book, you call the wrong person, even though the phone lines are perfect.

Private DNS zones

When you want your own internal names, such as orders.internal.example, you use an Azure Private DNS zone. You link the zone to one or more VNets, and only those VNets can see the names. You can add records yourself, or switch on auto-registration so virtual machines add their own names when they start and remove them when they are deleted.

Custom DNS servers

If you have your own DNS servers, for example Windows domain controllers, you can tell the VNet to use them instead. This is common in hybrid companies that need names from their offices to resolve in Azure and the other way around. Be careful: if the custom servers are unreachable, name lookups fail for every machine in the VNet. Always run at least two, in different places.

Azure DNS Private Resolver

The DNS Private Resolver is a managed service that forwards DNS questions between Azure and your on-premises network. It has inbound endpoints that your office servers can ask, and outbound endpoints with rules that decide where to send specific names. It replaces the old habit of running forwarding servers on virtual machines, which needed patching and care.

NeedTypical answer
Machines in one VNet find each otherDefault Azure DNS
Your own internal names across several VNetsPrivate DNS zone linked to each VNet
Office servers must resolve Azure private namesDNS Private Resolver inbound endpoint, or forwarders
Azure machines must resolve office namesDNS Private Resolver outbound endpoint with forwarding rules
Private endpoints to Azure servicesMatching private DNS zone for that service, linked to the VNet

DNS and private endpoints

This is where beginners most often stumble. When you create a private endpoint for a storage account, the service name, such as mystorage.blob.core.windows.net, must now resolve to the private address in your subnet instead of the public one. That requires a private DNS zone for that service, linked to your VNet. If you forget, the name still resolves to the public address, and your traffic goes the wrong way or gets blocked.

!
First suspect

When a connection to a private service fails and the network rules look correct, check DNS first. Look up the name from the machine that has the problem and see which address comes back. A surprising number of “network” problems turn out to be DNS problems.

14Private Access to Azure Services: Service Endpoints and Private Link

Azure storage, databases, and many other services normally have public addresses. There are two ways to reach them from your VNet without exposing that traffic more than necessary.

Service endpoints

A service endpoint is a switch you turn on for a subnet. It tells Azure that traffic from this subnet to a given service, such as Storage, should travel over Microsoft’s backbone and should carry the subnet’s identity. The service can then be locked down so it accepts requests only from chosen subnets. The destination still has a public address, but it refuses everyone else.

Private endpoints and Private Link

A private endpoint goes a step further. It creates a network interface with a private address inside your subnet that maps to one specific resource, such as one storage account or one database server. Azure Private Link is the technology behind it. Your applications connect to that private address, and the service’s public access can be turned off completely. The private endpoint can also be reached from peered VNets and from your offices over a VPN or ExpressRoute.

Analogy

A service endpoint is like a staff-only queue at a public bank: the bank is still on the main road, but your badge gets you into a special line, and the bank agrees to serve only badge holders. A private endpoint is like the bank building a private door inside your own office, wired directly to your account manager. Nobody outside your office even sees the door.

QuestionService endpointPrivate endpoint
Destination addressStill the service’s public addressA private address in your subnet
Reachable from on-premises through VPN or ExpressRouteNot directly in the same wayYes
ScopeWhole service type in a region, such as StorageOne specific resource
Protection against data leaving to other accountsWeaker, since the whole service is reachableStronger, since only that resource is reachable
Extra costNo extra chargeHourly and per-gigabyte charges
DNS workNoneRequired, using private DNS zones
Setup effortLowModerate

Which to choose

For quick, low-cost protection inside one region, service endpoints are easy. For stricter security, hybrid access, and the ability to close the public door entirely, private endpoints are usually the better answer. Many security standards now call for private endpoints on data services. Microsoft’s guidance and the supported services list change, so check current documentation.

Private Link for your own services

You can also offer your own service to other VNets or other companies through Private Link. Consumers create a private endpoint that points to your service behind a standard load balancer. This is a clean way to share an application without peering whole networks or exposing address ranges.

Network policies on private endpoint subnets

By default, network security group and route rules do not fully apply to traffic going to private endpoints. A setting on the subnet can turn on those network policies, so your rules and routes also affect the private endpoint traffic. Check current behavior before depending on it.

i
Good practice

Create a dedicated subnet for private endpoints. It keeps them tidy, makes rules simple, and avoids running out of addresses in application subnets.

15Security in Layers

No single control makes a network safe. Good security stacks several layers so that when one fails, another still stands. This idea is called defense in depth.

Analogy

A bank does not rely on one lock. There is a perimeter fence, a guarded entrance, cameras, a locked vault door, and a safe inside the vault. A thief must beat every layer. Your network deserves the same treatment.

Layer by layer

1

Edge protection

Use DDoS protection and a web application firewall at the entrance. Basic DDoS protection is applied automatically by the platform, and a paid tier adds tuning, reporting, and support for attacks on public IP addresses. A web application firewall blocks common web attacks such as injection attempts.

2

Central inspection

Azure Firewall inspects traffic that enters, leaves, or crosses between networks. It supports rules by address, by name, and by category, and higher tiers add intrusion detection and inspection of encrypted traffic.

3

Segmentation

Network security groups and subnets limit which tiers can talk to which. An attacker who gets into the web tier should find the data tier closed.

4

Safe administration

Azure Bastion lets administrators connect to machines through the browser over secure channels, without opening management ports to the internet or giving machines public addresses.

5

Private paths to data

Private endpoints keep traffic to databases and storage off the public side, and the public access of those services can be turned off.

6

Governance

Azure Policy and role-based access control decide who may create or change networks and what shapes are allowed. For example, you can forbid public IP addresses in certain subscriptions.

7

Identity and encryption

Strong sign-in and encrypted connections protect traffic even if someone gets onto the network.

Network security groups versus Azure Firewall

These two are not rivals; they do different jobs. A network security group is a simple, free filter that works on addresses, ports, and protocols, and it is attached to subnets and interfaces. Azure Firewall is a managed, central service that understands names, categories of websites, and threat intelligence, keeps logs in one place, and works across many VNets. Most serious designs use both.

FeatureNetwork security groupAzure Firewall
CostNo charge for the group itselfHourly and per-gigabyte charges
Filters by address, port, protocolYesYes
Filters by website nameNoYes
Intrusion detection and preventionNoYes, in higher tiers
Central across many VNetsNo; applied per subnet or interfaceYes
Best used forBasic segmentation inside a VNetPerimeter and inter-network control

Zero trust thinking

The old idea was that anything inside the network was trusted. Modern thinking assumes that an attacker may already be inside, so every connection should be checked, and every service should allow only what it needs. Segmentation, private endpoints, and identity checks all support this approach.

!
Common gap

The default network security group rules allow all traffic inside the VNet. Many teams leave this unchanged for years. If one machine is breached, the attacker can reach every other machine. Add explicit deny rules between tiers that should not talk.

16High Availability and Reliability

A network is like electricity: nobody thinks about it until it fails, and then nothing else works. Planning for failure is part of the design.

What a VNet itself survives

A VNet is a regional construct, and the platform keeps it running across the region’s datacenters. A VNet and its subnets are not tied to one availability zone; they span all the zones in the region. That means a single zone failure does not delete your network. What can fail are the things you place in it, and the paths that connect it.

Availability zones

Many regions have separate physical locations called availability zones, each with its own power, cooling, and networking. Spreading machines, gateways, firewalls, and load balancers across zones protects you from the loss of one location. When you choose public IP addresses, gateways, and firewalls, pick the zone-redundant options where they are offered.

Analogy

A shop that keeps all its stock and staff in one building is closed if that building floods. A shop with three branches in different parts of the city keeps serving customers when one branch is closed. Zones are the branches.

Multiple regions

If a whole region has trouble, only a design with another region can continue. This usually means a second VNet in another region with its own copies of the application, peered or connected to the first, and a global traffic manager such as Front Door or Traffic Manager choosing which region serves users. Address ranges for the two regions must not overlap.

Redundant connections

  • Gateways: use zone-redundant gateway options, or an active-active setup with two tunnels.
  • ExpressRoute: use two circuits, ideally via different providers or locations, and consider a VPN as backup.
  • Firewalls: deploy in zone-redundant mode so a single failure does not cut all traffic.
  • DNS: run at least two custom servers or use the managed resolver.
  • Outbound access: zone-aware NAT gateway setups should be checked against current guidance, since a NAT gateway attached to a subnet has its own zone behavior.

The network as a single point of failure

Central pieces, such as a hub firewall, carry traffic for many applications. If they fail, everything behind them is affected. Size them for peak load with room to spare, spread them over zones, and test failures regularly, not only on paper.

Infrastructure as code for recovery

If a network is lost or damaged, rebuilding it from stored templates is much faster and safer than remembering what it looked like. Keep all network definitions in version control. Resource locks can also protect critical network parts from accidental deletion.

ADR-01Accepted
Decision

Use zone-redundant gateways and firewalls in the hub, and keep all network definitions as code.

Reason

Central network services affect every application. A single zone loss should reduce capacity but not cut connectivity, and a damaged network should be rebuildable quickly from stored definitions.

Cost

Zone-redundant options may cost more, and the team must maintain and test the templates.

i
Practice failure

Run a drill where you take down one gateway or one zone on purpose, during a quiet period. Teams that rehearse failure find the hidden dependencies before a real outage does.

17Monitoring and Diagnostics

A network you cannot see is a network you cannot fix. Azure gives you tools to watch traffic, test connections, and find out exactly why something is blocked.

Network Watcher

Network Watcher is a collection of diagnostic tools that is enabled per region. It is the first place to go when something does not connect. Its most useful tools are:

Test

IP flow verify

Asks, “Would a packet with these details be allowed or denied on this machine?” and names the exact rule responsible.

Path

Next hop

Shows where traffic from a machine to a given address would be sent next, and which route table entry decided it.

View

Effective security rules and routes

Shows the combined result of all groups and routes that apply to a network interface, which is often different from what you assume.

Probe

Connection troubleshoot and Connection Monitor

Tests reachability, delay, and loss between two points, once or continuously over time.

Capture

Packet capture

Records actual packets on a virtual machine so experts can read exactly what was sent and received.

Map

Topology

Draws a picture of your network resources and how they link together.

Analogy

Network Watcher is the detective kit for your network. IP flow verify is asking the guard why a visitor was turned away. Next hop is checking which road the delivery van took. Packet capture is watching the security camera footage of the actual parcel being handed over.

Flow logs

A flow log is a record of the connections that passed through the network: who talked to whom, on which port, and whether the traffic was allowed. Historically, flow logs were collected at the network security group level. Microsoft has been introducing virtual network flow logs, which record traffic at the VNet level and cover more cases, and has announced a move away from the older group-level logs. The exact timeline for retirement and the migration steps should be checked in current documentation before you plan.

Flow logs are stored in a storage account. With Traffic Analytics, the logs are processed in a Log Analytics workspace to show top talkers, busiest ports, blocked traffic, and traffic between regions, in charts you can browse.

Other signals to collect

  • Metrics from gateways, firewalls, NAT gateways, and load balancers, such as throughput, dropped packets, and SNAT port use.
  • Diagnostic logs from firewalls and gateways sent to a Log Analytics workspace.
  • Activity logs showing who changed a network resource and when.
  • Alerts for events such as a tunnel going down, a sudden traffic spike, or a configuration change.

What to watch

SignalWhy it matters
VPN tunnel statusA down tunnel means the office has lost its path to Azure
ExpressRoute circuit state and bandwidth useWarns before a saturated line slows the business
NAT gateway SNAT connection count and dropsEarly sign of port exhaustion
Firewall throughput and healthCentral devices can become bottlenecks
Denied traffic countsMay show attacks, or misconfigured applications
Free addresses per subnetRunning out blocks deployments and scaling
Configuration changesUnexpected changes are a common cause of outages and breaches
i
Turn it on before you need it

Flow logs and diagnostics cannot tell you about yesterday if you switch them on today. Enable logging as part of building the network, and set a retention period that fits your rules and budget.

18Cost and Optimization

The VNet is free, but the services around it are not. Network costs often surprise teams because they are spread across many small meters.

What costs nothing

  • The virtual network, its subnets, and the address space.
  • Network security groups, route tables, and application security groups.
  • Traffic between resources inside the same VNet and the same region, as a general rule.
  • Inbound data from the internet into Azure.

What costs money

ItemHow it is chargedTypical way to save
VPN gatewayPer hour by size, plus data leaving AzureRight-size the SKU; share one gateway through gateway transit
ExpressRouteCircuit fee, provider fee, and optional data charges depending on planPick the right bandwidth and plan type; share a circuit across VNets
Azure FirewallPer hour by tier, plus data processedUse one central firewall; pick the lowest tier that meets your needs
Azure BastionPer hour by tier, plus outbound dataUse one per hub rather than per VNet; delete it in test environments when idle
NAT gatewayPer hour, plus per gigabyte processedUse private endpoints to avoid sending Azure-bound traffic through it
Public IP addressesPer hour for each Standard addressDelete unattached addresses; avoid one per machine
VNet peeringPer gigabyte in each direction; higher for global peeringPlace chatty systems in the same VNet or region
Private endpointsPer hour, plus per gigabyte processedShare endpoints across applications where policy allows
Internet egressPer gigabyte leaving Azure, with a small free allowanceUse a content delivery network, compress data, and keep traffic in the region
Application Gateway and Load BalancerPer hour and per capacity or dataShare one gateway across many sites where design allows
Flow logs and Traffic AnalyticsStorage and log analytics ingestionFilter what you collect; set retention carefully
Analogy

Building the road is free, but every toll booth, bridge, and guard post on the road has a bill. The more booths you build, and the more cars pass through them, the larger the total. Saving money means building fewer booths and sending less traffic through the expensive ones.

Where the big surprises come from

  • Data crossing regions. A chatty application split across two regions can create large peering and egress bills.
  • Forgotten test gateways. A gateway or firewall left running in a test subscription costs money every hour of every day.
  • Everything through the firewall. Sending bulk traffic, such as backups, through a firewall billed per gigabyte adds up quickly. Consider exceptions where policy allows.
  • NAT gateway for Azure services. Traffic to storage through a NAT gateway is charged per gigabyte, but a private endpoint or service endpoint can avoid that path.

A simple routine

1

Tag everything

Label network resources with owner and project, so costs can be shared out fairly.

2

Review monthly

Look at the cost analysis by resource type. Gateways, firewalls, and data transfer are the usual suspects.

3

Delete the unused

Find unattached public IP addresses, idle gateways, and empty test networks.

4

Right-size

Compare real throughput to the SKU. Move down a size where the numbers allow, and up before a limit is hit.

i
Check current prices

Prices and meter names change often and differ by region. Use the Azure pricing calculator for estimates, and treat any figure you read in a blog post as a starting point only.

19Design Patterns and Decisions

Experienced architects record their big choices as short decision notes. Here are common decisions for virtual networks, written in that style, so you can see how the reasoning goes.

ADR-02Accepted
Decision

Adopt a hub-and-spoke topology with a central firewall and one shared gateway.

Reason

The company expects many applications and teams. A hub keeps shared services in one place, enforces inspection between spokes, and avoids paying for a gateway in every network.

Cost

The hub becomes critical and must be designed for resilience and capacity. Spoke-to-spoke traffic passes through the hub and adds a small delay.

ADR-03Accepted
Decision

Reserve one large address block for all Azure networks and keep a central register of allocations.

Reason

Overlapping ranges block peering and hybrid links. A single plan prevents that problem before it exists.

Cost

Someone must own the register, and teams must ask before creating networks. The process feels slow until the first avoided clash.

ADR-04Accepted
Decision

Use private endpoints for databases and storage, and disable public access on those services.

Reason

Sensitive data should never be reachable from the open internet, and private endpoints limit access to one specific resource.

Cost

Private DNS must be set up correctly, and there is an hourly and per-gigabyte charge.

ADR-05Proposed
Decision

Use a NAT gateway on application subnets for outbound internet access, and avoid public addresses on individual machines.

Reason

Stable outbound addresses help partners allow our traffic, and nothing from the internet can start a connection to the machines.

Cost

Hourly and per-gigabyte charges apply, and port exhaustion must be monitored on busy applications.

Patterns that work

Pattern

Landing zone

A ready-made, governed set of subscriptions and networks with rules built in, so new teams start from a safe baseline.

Pattern

Hub and spoke

A shared hub with gateways and firewalls, and separate spokes for each application or team.

Pattern

Tiered subnets

Web, application, and data layers in separate subnets with rules between them.

Pattern

Private by default

No public addresses except at the front door, and private endpoints for platform services.

Pattern

Environment separation

Separate networks for production and non-production, so a test mistake cannot touch live systems.

Pattern

Network as code

All definitions kept in version control and deployed through reviewed pipelines.

Anti-patterns to avoid

Avoid these

  • Using the same address range in every project
  • One giant subnet holding everything
  • Public IP addresses on database servers
  • Management ports open to the internet
  • Hand-built networks with no code behind them
  • No logging until after an incident

Do these instead

  • Plan one company-wide address map
  • Separate subnets by role and security need
  • Private endpoints for data services
  • Bastion or restricted admin ranges
  • Templates in version control
  • Flow logs and alerts from day one
A good network design is mostly decisions you wrote down before anyone needed to ask.

20Best Practices and Common Mistakes

This chapter gathers the lessons that most teams learn the hard way. Learn them the easy way, by reading them first.

Best practices

  • Plan addresses first. Build a single register and check every new range against it.
  • Give subnets room. Leave at least a third of the address space free for growth.
  • Segment by role. Use separate subnets for web, application, data, management, and platform services.
  • Attach a network security group to every subnet that supports it, and write rules by role using application security groups and service tags.
  • Keep machines private. Give public addresses only to front-door services.
  • Use private endpoints for data services and turn off public access where possible.
  • Control outbound traffic. Use a NAT gateway or firewall and avoid reliance on any default outbound behavior.
  • Use code. Define networks in templates and deploy through reviewed pipelines.
  • Log and alert. Enable flow logs, diagnostics, and alerts for connectivity and configuration changes.
  • Use policy. Enforce rules such as required tags, allowed regions, and forbidden public addresses.
  • Document the intent. Write why each rule or route exists, in its name or description.
  • Test failure. Practice losing a zone, a gateway, or a DNS server.

Common mistakes

MistakeWhat goes wrongBetter approach
Overlapping address rangesPeering and VPN links cannot be createdCentral address register before building
Subnets sized exactly for todayNo room for scaling or upgradesPlan for growth and temporary extra instances
Forgetting the five reserved addressesA small subnet holds fewer machines than expectedSubtract five when sizing
Assuming peering is transitiveSpokes cannot reach each otherRoute through a hub firewall or peer directly
Open management portsBrute-force attacks and compromiseUse Bastion or restricted ranges
Wide allow rules at low priority numbersLater, stricter rules never get evaluatedOrder rules carefully and review regularly
Missing private DNS for private endpointsNames resolve to public addressesCreate and link the matching private DNS zone
Relying on default outbound accessOutbound addresses change or the feature disappearsProvide an explicit outbound method
Routing everything through a firewall without return pathsAsymmetric routing and dropped connectionsCheck routes in both directions
No loggingNothing to investigate after an incidentEnable logs early with sensible retention
Manual changes in the portalDrift from the code and from memoryChange through code; limit portal rights
Analogy

Think of these practices as the habits of a careful builder: measure twice, leave space for extensions, lock every door, label every switch, and keep the blueprints. None of them is exciting, but together they are the difference between a building that stands for decades and one that needs a rescue every winter.

!
The expensive one

The most costly mistake in the list is the first one. Renumbering a live network means moving every machine, changing every rule, and updating every connection. Spend your planning time on addresses.

21Real-World Usage Scenarios

Let us look at typical ways organizations use virtual networks. These are common patterns described in general terms, not accounts of any named company.

A typical online retailer

A retail company runs a website, an order system, and a database. The website sits behind an application gateway with a web application firewall. Web servers live in one subnet, order services in another, and the database is reached through a private endpoint in a third. A NAT gateway gives the order service a fixed outbound address that the payment provider has approved. During a sale, scale sets add web servers automatically, and the web subnet is large enough to hold them. The team had to learn early that a subnet sized only for the usual load cannot grow during peak days.

A typical bank moving gradually

A financial company keeps its core systems in its own data center and moves new applications to Azure. An ExpressRoute circuit joins the two, with a VPN as backup. A hub VNet holds the gateway, a firewall, and DNS resolvers. Each application lives in a spoke, and all traffic between spokes and to the office passes through the firewall for inspection and logging. Databases use private endpoints, and public access is disabled by policy. Auditors can follow traffic through the central logs.

A typical software company with many teams

A software firm gives each product team its own subscription with a spoke VNet, created from a standard template through a pipeline. Address ranges are handed out from a central register. Azure Policy blocks public addresses on virtual machines and requires network security groups on subnets. Virtual Network Manager helps connect new spokes to the hub automatically. Teams move fast because the safe network is the easy path.

A typical container platform

A team runs Kubernetes on Azure. With the Azure CNI networking option, every pod can receive an address from the subnet, which can consume thousands of addresses very quickly. The team sizes the subnet accordingly, or chooses an overlay mode that conserves addresses, and checks current documentation for the differences. The lesson is that container platforms can consume address space many times faster than virtual machines.

Platform services that use your network

Web apps

App Service VNet integration

Lets a web app make outbound calls into your VNet, so it can reach private databases. It uses a delegated subnet.

Database

SQL Managed Instance

Lives inside your VNet in a delegated subnet, so it has a private address and follows your rules.

Containers

AKS and Container Apps

Place nodes and sometimes pods into subnets you control, and need careful address planning.

Compute

Virtual machines and scale sets

Connect through network interfaces to your subnets and use your groups and routes.

Data

Storage, Key Vault, and databases

Reach through private endpoints so data never takes a public path.

Files

Delegated file and database services

Some managed services place their own interfaces in your subnet and require delegation.

Landing zones

A landing zone is a pre-built, governed foundation, with networks, policies, identity, and logging already in place, where new workloads can land safely. Microsoft’s Cloud Adoption Framework describes reference designs for these. Larger organizations often start here rather than building networks one project at a time.

Analogy

A landing zone is like a planned industrial park. Roads, power, fences, and fire rules are provided before any factory opens. New companies move in and start work quickly, and they cannot accidentally block the road for everyone else.

22Troubleshooting

When something cannot connect, guessing wastes hours. A calm, ordered approach finds the cause quickly.

A method that works

1

Define the problem exactly

Write down the source, the destination, the port, and what error appears. “It does not work” cannot be diagnosed.

2

Check the name

If a name is used, confirm it resolves to the address you expect from the machine with the problem.

3

Check the filters

Use IP flow verify or effective security rules to see if a group is blocking the traffic, in either direction.

4

Check the route

Use next hop or effective routes to confirm where the traffic goes, and that a return path exists.

5

Check the destination

Confirm the service is listening, its own firewall allows the source, and it is healthy.

6

Look at the logs and capture packets

Flow logs show whether traffic was allowed. A packet capture shows what really arrived and what came back.

Common symptoms and likely causes

SymptomLikely causesFirst check
Cannot connect to a VM from the internetNo public address, security group blocks the port, or the machine’s own firewall blocks itIP flow verify on the inbound port
Two VMs in the same VNet cannot talkCustom deny rule, machine firewall, or wrong portEffective security rules on both interfaces
Peered VNets cannot reach each otherPeering not connected on both sides, overlapping ranges, or rules blockingPeering status on both VNets
Spoke cannot reach another spokePeering is not transitive; no route to the hub firewallNext hop from the source machine
Cannot reach office networkTunnel down, missing routes, or overlapping address rangesGateway connection status and effective routes
Private endpoint name resolves to a public addressPrivate DNS zone missing or not linked to the VNetLook up the name from the affected machine
Random outbound failures under loadSNAT port exhaustionNAT gateway metrics for dropped connections
Connections time out only sometimesAsymmetric routing through a firewall, or an overloaded deviceCompare outbound and return routes
New machine fails to deploy in a subnetSubnet out of addresses, or a delegation conflictRemaining addresses in the subnet
Everything fails to resolve namesCustom DNS server down or unreachableDNS server settings on the VNet
Analogy

Troubleshooting a network is like finding why a parcel never arrived. You check the address on the label, then whether the gate let the courier in, then which road the van took, then whether anyone was home. Going in order saves you from searching the whole city.

i
Change one thing at a time

When you try fixes, change one thing, test, and record the result. Changing five things at once may fix the problem, but you will never know which change did it, and you may leave behind a hole in your security.

23Frequently Asked Questions

Quick answers to questions that beginners ask most often.

1Does a virtual network cost money?
The VNet and its subnets are free. You pay for things you add around it, such as gateways, firewalls, NAT gateways, public addresses, private endpoints, peering data, and internet egress.
2Can one VNet span multiple regions?
No. A VNet lives in one region and one subscription. To use several regions, create a VNet in each and connect them with global peering or a gateway.
3Can I change the address space later?
You can usually add more ranges to a VNet. Changing or removing a range that has subnets in use is restricted, and changing a range on a peered VNet may require refreshing the peering. Plan carefully so you do not depend on this.
4How many addresses are lost in each subnet?
Five. They are used for the network, the gateway, two for Azure’s DNS handling, and the broadcast address.
5Do machines in different subnets of the same VNet talk by default?
Yes. The default routes and the default security rules allow traffic between subnets of the same VNet. Add your own rules if you want to restrict it.
6What is the difference between an NSG and Azure Firewall?
An NSG is a simple, free filter based on addresses, ports, and protocols, attached to subnets or interfaces. Azure Firewall is a central managed service with richer features such as name-based rules and threat detection, and it charges by the hour and by data.
7Is peering transitive?
No. If A is peered to B and B to C, A cannot reach C unless you peer them directly or route traffic through a firewall or router in B.
8Is VNet peering traffic encrypted?
Peered traffic stays on Microsoft’s backbone, not on the public internet. Whether you need additional encryption depends on your requirements, so use TLS between sensitive services and check current documentation for platform-level encryption options.
9Should I use a VPN or ExpressRoute?
A VPN is quick and affordable, and good for smaller or backup needs. ExpressRoute is a private line with steadier performance and higher cost, suited to heavy or sensitive workloads. Many companies use both.
10Do my machines need public IP addresses to reach the internet?
No. Use a NAT gateway, a load balancer with outbound rules, or a firewall. Avoid depending on default outbound access, since it is being phased out for new networks.
11What is the difference between a service endpoint and a private endpoint?
A service endpoint keeps traffic on Microsoft’s network and lets the service accept only chosen subnets, but the service keeps its public address. A private endpoint gives the service a private address in your subnet, and you can turn public access off.
12Why does my private endpoint not work?
Most often DNS. The service name must resolve to the private address, which requires the matching private DNS zone linked to your VNet. Also check network rules and that the endpoint is approved.
13How big should my VNet be?
Larger than you think you need. A /16 per application or environment is common in large companies, with room reserved for growth. The cost of a large range is zero, while the cost of a cramped one is high.
14How do I protect against attacks from the internet?
Use layers: DDoS protection, a web application firewall, a firewall for inspection, network security groups, private endpoints, and secure administration with Bastion. Keep machines private and log everything.
15Where should I start learning more?
Start with the Azure documentation for virtual networks, then practice by building a small three-tier network with network security groups, a NAT gateway, and a peering to a second VNet. Reading the Cloud Adoption Framework helps with larger designs.

24Summary and Key Takeaways

A virtual network is the foundation of nearly everything you build in Azure. It is free, flexible, and powerful, and it rewards careful planning at the start.

In this guide you met the VNet as a private neighborhood inside Azure, learned how addresses and subnets divide it, followed a message across it, and saw how security groups, routes, and DNS shape what happens. You compared peering, VPNs, and ExpressRoute for connecting networks, and service endpoints and private endpoints for reaching Azure services privately. You saw how to layer security, plan for failure, watch the network, control cost, and avoid the classic mistakes.

Key Takeaways

  • Plan addresses first. Overlapping ranges are the most expensive mistake, and a company-wide address register prevents it.
  • Subnets are security boundaries. Separate web, application, data, management, and platform services, and leave room to grow.
  • Remember the five reserved addresses. They shrink small subnets more than most people expect.
  • Filters and routes decide everything. Network security groups use priority order, and routing picks the most specific match.
  • Peering is private but not transitive. Use hub-and-spoke with a central firewall when spokes need to talk to each other.
  • Keep resources private. Use private endpoints, explicit outbound access, and Bastion, and set up DNS carefully.
  • Observe and automate. Turn on logs early, keep networks in code, watch costs, and rehearse failure.