Skip to content
Tutorials Center
My learning

Topics

Lesson 23 of 57 ยท Networking

Private Endpoints, VPN and ExpressRoute

Learn Azure private connectivity: Private Link and Private Endpoints vs service endpoints, VPN Gateway, ExpressRoute and hub-and-spoke design, with runnable reachability models.

Most Azure services are born with a public address. A storage account, a SQL server or a Key Vault answers on a name that anyone on the internet can resolve, and only authentication and firewall rules stand between the world and your data. Many organizations want more: they want the service reachable only over private addresses, and they want their own offices and data centers to connect to Azure without crossing the public internet.

This lesson covers the building blocks for that: Private Link and Private Endpoints for reaching Azure services privately, VPN Gateway and ExpressRoute for linking on-premises networks to Azure, and the hub-and-spoke layout that ties it together. The real services need an account, so the commands are read-only, and the runnable examples are JavaScript models of reachability. They simplify a lot, but they capture the rules that decide whether a connection works. Revisit Virtual Networks and Subnets and DNS and Traffic Manager if peering or private DNS zones are unfamiliar.

A Private Endpoint is a network interface placed in one of your subnets. It receives a private IP address from that subnet and is wired to one specific instance of an Azure service, for example the blob service of one storage account, or one SQL server. Traffic to that private IP travels over the Microsoft backbone and never touches the public internet. The technology behind it is called Azure Private Link. The same mechanism lets you publish your own service (placed behind a Standard Load Balancer) to customers through a Private Link Service, without peering their network to yours.

Two details decide whether it works in practice:

  1. A private endpoint targets a sub-resource. A storage account has separate endpoints for blob, file, queue, table and dfs, and you create one private endpoint per sub-resource you need.
  2. DNS must resolve the service name to the private IP. Applications keep using the normal name, stshop.blob.core.windows.net. Azure makes that name a CNAME to stshop.privatelink.blob.core.windows.net. A private DNS zone called privatelink.blob.core.windows.net, linked to your VNet, holds an A record with the private IP. Callers inside the network get the private address; everyone else still gets the public one. Forgetting the DNS part is the number one cause of "my private endpoint does not work".

After the endpoint is in place you normally turn off public network access on the service, so the private IP becomes the only way in.

Terminal
az network private-endpoint create \
  --resource-group rg-net --name pe-stshop-blob \
  --vnet-name vnet-app --subnet snet-data \
  --private-connection-resource-id $(az storage account show -n stshop -g rg-net --query id -o tsv) \
  --group-id blob --connection-name conn-stshop-blob

az storage account update --name stshop --resource-group rg-net --public-network-access Disabled

Private Endpoint versus service endpoint

You met service endpoints in the virtual networks lesson. Both keep traffic on the backbone, but they differ in an important way, and the next model makes the difference visible. For each setup it shows what address a caller resolves and whether the connection is allowed.

JS Public, service endpoint or private endpoint?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

With a service endpoint the address stays public and only the subnet's identity changes, so the on-premises server is blocked: it comes from outside the subnet. With a private endpoint the service has an address inside your network, which on-premises networks can reach through a VPN or ExpressRoute link. Service endpoints are free and simple; Private Endpoints cost a little per hour and per gigabyte but give true private addressing, access from on-premises, and protection against data exfiltration to other accounts of the same service.

Connecting on-premises networks

VPN Gateway

A VPN Gateway creates an encrypted IPsec/IKE tunnel over the public internet between Azure and another network. It lives in a special subnet named GatewaySubnet and comes in different SKUs that determine throughput and the number of tunnels. Common connection types:

  • Site-to-site (S2S): connects an office or data center router to your VNet, available around the clock.
  • Point-to-site (P2S): lets an individual laptop dial in, useful for remote administrators.
  • VNet-to-VNet: connects two VNets with a tunnel (peering is usually better for that).

For availability, use an active-active gateway with two public IPs and a zone-redundant SKU. VPN is quick to set up and inexpensive, but throughput is limited and latency varies because it rides the internet.

Terminal
az network vnet-gateway create \
  --resource-group rg-net --name vpngw-hub \
  --vnet vnet-hub --public-ip-addresses pip-vpngw \
  --gateway-type Vpn --vpn-type RouteBased --sku VpnGw1

ExpressRoute

ExpressRoute is a dedicated private connection between your network and Microsoft, set up through a connectivity provider or direct port at an exchange location. It does not cross the public internet, which gives more predictable latency, higher bandwidth, and an SLA. A connection is called a circuit. Private peering reaches your VNets, and Microsoft peering reaches Microsoft 365 and public Azure service endpoints. Two things to remember: ExpressRoute is not encrypted by default (add MACsec on ExpressRoute Direct, or run an IPsec VPN over it, if policy demands it), and a single circuit is a single dependency, so serious designs use redundant circuits, and often keep a VPN as a backup path.

VPN Gateway ExpressRoute
Path Encrypted tunnel over the internet Private link through a provider
Setup time Minutes to hours Days to weeks
Bandwidth and latency Limited, variable Higher, more predictable
Cost Lower Higher (circuit plus provider fees)
Typical use Small offices, backups, remote users Large data volumes, strict latency or compliance needs

Hub-and-spoke

Hundreds of workloads would be unmanageable if every VNet were connected to every other one. The standard answer is hub-and-spoke. A central hub VNet holds shared services: the VPN or ExpressRoute gateway, a firewall, Bastion and DNS. Each workload lives in its own spoke VNet, peered to the hub only. Spokes are isolated from each other by default, because peering is not transitive; when you do want spoke-to-spoke traffic or on-premises access, it flows through the hub, where it can be inspected.

flowchart TB
    OP["On-premises network"] -->|"VPN or ExpressRoute"| H["Hub VNet<br/>gateway, firewall, Bastion"]
    H ---|"peering"| S1["Spoke: web app"]
    H ---|"peering"| S2["Spoke: data platform"]
    S1 -. "not directly connected" .- S2

Spokes talk to the hub and, through it, to each other and to on-premises. They never need to be peered together.

Two peering settings make the hub useful. On the hub side of each peering, enable Allow gateway transit; on the spoke side, enable Use remote gateways. Then the spokes use the hub's gateway to reach on-premises, with no gateways of their own. For spoke-to-spoke traffic, attach a route table to each spoke subnet with a route for the other spoke (or 0.0.0.0/0) whose next hop is the firewall's private IP.

The next model computes reachability for three configurations of the same layout: bare peering, then adding the hub firewall with user-defined routes, then adding gateway transit.

JS Hub-and-spoke reachability

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The model is a deliberate simplification. Real routing also involves security rules and the exact route tables on each subnet, and a firewall still needs rules that allow the traffic. But the lesson holds: connectivity in Azure is something you design in layers (peering, routes, gateways, rules), and each layer must agree before a packet gets through. When something cannot connect, walk the layers one by one: addresses, routes, NSG rules (see Network Security Groups and Firewalls), then DNS.

Virtual WAN

When the number of sites and VNets grows large, hand-building hubs becomes laborious. Azure Virtual WAN is a managed hub-and-spoke service that provisions hubs with VPN, ExpressRoute and firewall integration and handles the routing between branches and VNets for you. It suits organizations with many branch offices; for a handful of VNets, a self-managed hub is usually enough.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does a Private Endpoint give a storage account that a service endpoint does not?

    A Private Endpoint is a network interface with a private IP in your subnet. A service endpoint leaves the service on its public address.
  2. 2. A Private Endpoint exists but the application still connects to the public IP. What is the most likely cause?

    The service name must resolve to the private IP through a linked private DNS zone. Without it, clients keep resolving the public address.
  3. 3. Which connection option does not cross the public internet?

    ExpressRoute uses a private circuit through a connectivity provider. VPN tunnels run over the internet.
  4. 4. In a hub-and-spoke design, why can two spokes peered only to the hub not talk to each other by default?

    VNet peering connects exactly two networks. Spoke-to-spoke traffic requires routes (user-defined routes) pointing at a firewall or virtual appliance in the hub.
  5. 5. Which pair of settings lets spokes use the hub's VPN gateway?

    Gateway transit shares the hub's gateway, and the spoke opts in with Use remote gateways.

Summary

  • A Private Endpoint places a service on a private IP in your subnet via Private Link; it needs a linked private DNS zone and usually public access disabled.
  • Service endpoints keep the public address and only add subnet identity; Private Endpoints enable on-premises access and finer isolation.
  • VPN Gateway builds encrypted tunnels over the internet; ExpressRoute is a private circuit with better predictability and higher cost, and is not encrypted by default.
  • Hub-and-spoke centralizes gateways, firewalls and DNS in a hub, peers each workload as a spoke, and routes shared traffic through the hub.
  • Debug connectivity layer by layer: addresses, routes, NSG rules, DNS.

Next: Azure SQL Database.