VPN & ExpressRoute: Hybrid Connectivity

Connect your on-premises data center to Azure securely β€” over the internet or a dedicated circuit
🟑 Intermediate ⏱ 20 Minutes πŸ“˜ AZ-104 Β· Module 04
Why This Matters

You have Azure VNets in the cloud, but your company still has an on-premises data center. You need to connect them securely. You have two choices: VPN (cheaper, over the internet) or ExpressRoute (dedicated, more expensive, better performance). This doc explains both, when to use each, and how they work.

Before You Start

PrerequisitesVNets & Subnets, Routing Fundamentals, VNet Peering
Time to understand20 minutes
Difficulty🟑 Intermediate (builds on routing)
What you'll learnHow VPN and ExpressRoute work, comparison, when to use each

The Simple Idea

What Is Hybrid Connectivity?

Hybrid = Connecting on-premises infrastructure to Azure cloud.

You need this when:

  • Your company has servers in the data center (on-premises)
  • You also have resources in Azure (VMs, databases, apps)
  • They need to communicate securely

Two Solutions

SolutionConnectionBandwidthLatencyCostSecurity
VPNOver internet (encrypted)Up to 1.25 GbpsHigh (~100ms)LowGood (encryption)
ExpressRouteDedicated circuit from providerUp to 100 GbpsLow (~5ms)HighExcellent (isolated)

Option 1: VPN Gateway

What Is a VPN?

VPN (Virtual Private Network) = Secure tunnel over the public internet that encrypts all traffic.

Real-World Analogy: Armored Truck Through Public Roads

An armored truck carries secret documents through public roads. Attackers can see the truck, but can't access its contents. The Azure VNet receives and decrypts the documents, which are then safely used in cloud services.

On-Premises Office β”‚ β”œβ”€β”€ Secret documents β”‚ └── Send via: Armored Truck (encrypted) └─ Drives through public roads └─ Attackers can see the truck, but can't access contents βœ“ ↓ (Internet) Azure VNet β”‚ β”œβ”€β”€ Documents received and decrypted β”‚ └── Safely used in cloud services βœ“

How VPN Works

Step 1: On-premises router has VPN client └─ Initiates secure tunnel to Azure VPN Gateway Step 2: Encryption happens automatically └─ All traffic encrypted before leaving on-premises └─ Travels over internet └─ Decrypted by Azure VPN Gateway Step 3: Azure VPN Gateway decrypts and forwards └─ Forwards to VNets connected to it └─ Return traffic encrypted again Result: On-premises ═══(Encrypted Tunnel)═══ Azure β”‚ (Over Internet) β”‚ └─ Secure but slower (encryption overhead) └─ Good for moderate bandwidth needs

VPN Configuration & Use Cases

VPN Configuration

On-Premises: β”œβ”€ VPN Gateway (on router) β”œβ”€ Pre-shared key or certificate └─ Routes: "To reach 10.0.0.0/16 (Azure), use VPN tunnel" Azure: β”œβ”€ VPN Gateway in VNet β”œβ”€ Connection resource linking on-prem gateway to Azure gateway └─ Routes: "To reach 192.168.0.0/16 (on-prem), use VPN tunnel" Handshake: On-prem: "Can I reach 10.0.0.0/16?" Azure VPN: "Yes, authenticate with pre-shared key" Tunnel established βœ“

Use VPN When

β”œβ”€ Need to connect quickly (days, not weeks) β”œβ”€ Low-to-medium bandwidth (< 1 Gbps) β”œβ”€ Budget-conscious (cheaper than ExpressRoute) β”œβ”€ Can tolerate higher latency (100ms+) β”œβ”€ Example: Backup a database nightly to Azure β”‚ (doesn't need constant, low-latency connection)

Don't Use VPN If

β”œβ”€ Need very high bandwidth (> 1 Gbps) β”œβ”€ Need consistent low latency (< 10ms) β”œβ”€ Transmitting HD video or real-time data └─ Example: Don't run production SQL server queries over VPN

Option 2: ExpressRoute

What Is ExpressRoute?

ExpressRoute = Dedicated, private network circuit from your on-premises to Azure (not over the internet).

Real-World Analogy: Private Highway Just For You

A private highway, dedicated and isolated, only you can use. No encryption needed because it's already isolated β€” much faster and more reliable. Documents are received immediately and safely used in cloud services.

On-Premises Office β”‚ β”œβ”€β”€ Secret documents β”‚ └── Send via: Private highway (dedicated, isolated) └─ Only you can use this highway └─ No encryption needed (already isolated) └─ Much faster and more reliable βœ“ ↓ (Dedicated Circuit - not internet) Azure VNet β”‚ β”œβ”€β”€ Documents received immediately β”‚ └── Safely used in cloud services βœ“

How ExpressRoute Works

Step 1: Order dedicated circuit from provider └─ Provider creates private circuit: On-prem β†’ Azure DC └─ Takes 2-4 weeks to provision Step 2: Circuit arrives (dedicated link) └─ Not encrypted (no needβ€”it's isolated) └─ High bandwidth available (1.25, 10, 100 Gbps options) Step 3: BGP routing configured └─ "Routes to 10.0.0.0/16 (Azure) go through this circuit" └─ "Routes to 192.168.0.0/16 (on-prem) come from this circuit" Result: On-premises ═══(Dedicated Circuit)═══ Azure β”‚ (Private, No Internet) β”‚ └─ Secure (isolated by nature) └─ Fast (low latency, high bandwidth) └─ Predictable (dedicated resource)

ExpressRoute Peering Models & Pricing

ExpressRoute Peering Models

Azure supports multiple connections over one ExpressRoute circuit:

ExpressRoute Circuit β”œβ”€ Private Peering (Azure VNets) β”‚ └─ Connect to your Azure VNets (10.0.0.0/16, etc.) β”‚ └─ Private IP addresses used β”‚ └─ Lowest latency β”‚ β”œβ”€ Microsoft Peering (Microsoft Services) β”‚ └─ Connect to Office 365, Dynamics, Azure Services β”‚ └─ Public IP addresses used β”‚ └─ Can reach Microsoft services without internet β”‚ └─ Azure Public Peering (Deprecated, avoid) └─ Older model, being phased out

ExpressRoute Pricing Models

Unlimited Data (Most common): β”œβ”€ Monthly fee + Fixed amount of bandwidth β”œβ”€ Example: $100/month for 1 Gbps circuit β”œβ”€ All data transfers included βœ“ Metered Data (Cheaper if low usage): β”œβ”€ Monthly fee + Per-GB charges for outbound β”œβ”€ Example: $50/month + $0.02/GB outbound β”œβ”€ Good if only occasional transfers └─ Note: Inbound is always free βœ“

Comparison: VPN vs. ExpressRoute

AspectVPNExpressRoute
CostLow ($10-50/month)High ($100-1000+/month)
Setup TimeFast (days)Slow (weeks)
BandwidthUp to 1.25 GbpsUp to 100 Gbps
LatencyHigh (~100ms)Low (~5ms)
ReliabilityMedium (shared internet)High (dedicated)
EncryptionBuilt-inNot needed (isolated)
SecurityGood (encryption)Excellent (isolation)
Best ForQuick, temporary, low bandwidthProduction, high throughput

Decision Tree

Need to connect on-premises to Azure? β”‚ β”œβ”€ YES β†’ Have dedicated budget? β”‚ β”‚ β”‚ β”œβ”€ NO β†’ Use VPN Gateway βœ“ β”‚ β”‚ └─ Good for: backup, development, non-critical workloads β”‚ β”‚ β”‚ └─ YES β†’ Need high bandwidth or low latency? β”‚ β”‚ β”‚ β”œβ”€ NO β†’ Use VPN Gateway βœ“ β”‚ β”‚ └─ Cheaper, fast to set up β”‚ β”‚ β”‚ └─ YES β†’ Use ExpressRoute βœ“ β”‚ └─ Production, mission-critical, real-time data β”‚ └─ NO β†’ Don't connect on-prem βœ“ └─ Cloud-only architecture (simpler)

Worked Example: Real Scenario

The Scenario

TechCorp has:

  • On-premises: Data center with SQL servers (192.168.0.0/16)
  • Azure: Production VNet (10.0.0.0/16) and Dev VNet (10.1.0.0/16)

Requirement: Migrate workloads incrementally (dual-run for weeks).

Solution 1: VPN for Initial Migration

Phase 1 (Weeks 1-4): Use VPN for testing └─ On-premises β†’ VPN Gateway β†’ Azure Prod VNet └─ Test applications in Azure while old systems still running └─ Cost: ~$30/month VPN + internet bandwidth └─ Latency: ~100ms (acceptable for testing) βœ“ Configuration: β”œβ”€ On-prem VPN Gateway: Configured for site-to-site VPN β”œβ”€ Azure VPN Gateway in Prod VNet β”œβ”€ Pre-shared key or certificates β”œβ”€ Routes: β”‚ β”œβ”€ On-prem: 192.168.0.0/16 local, 10.0.0.0/16 via VPN β”‚ └─ Azure: 10.0.0.0/16 local, 192.168.0.0/16 via VPN Testing: β”œβ”€ App server in Azure (10.0.1.5) queries on-prem SQL (192.168.1.50) β”œβ”€ Latency: ~100ms (acceptable for testing) βœ“ └─ VPN encrypts all traffic βœ“ Cost: Low (good for temporary connection)

Solution 2: Migrate to ExpressRoute (Phase 2)

Phase 2 (Weeks 5+): Switch to ExpressRoute for production └─ Order dedicated circuit: Takes 3 weeks to provision └─ While waiting, continue testing over VPN Configuration: β”œβ”€ ExpressRoute Circuit provisioned β”‚ β”œβ”€ Provider: Equinix (or other partner) β”‚ β”œβ”€ Bandwidth: 10 Gbps β”‚ β”œβ”€ Location: Same city as data center β”‚ └─ Monthly cost: ~$500 β”‚ β”œβ”€ Azure side: Create ExpressRoute gateway β”‚ β”œβ”€ Private Peering for VNets β”‚ └─ Routes updated to use ExpressRoute for all on-prem traffic β”‚ └─ On-premises side: BGP configured for routing Result: β”œβ”€ High bandwidth available (10 Gbps vs. VPN's 1.25 Gbps) β”œβ”€ Low latency (~5ms vs. VPN's 100ms) β”œβ”€ Production workloads move to Azure with good performance βœ“ └─ Cost higher but worth it for mission-critical apps

Phase 3: Dual Connectivity (Redundancy)

For production reliability: Use BOTH VPN and ExpressRoute VPN + ExpressRoute together: β”œβ”€ ExpressRoute: Primary (low latency, high bandwidth) β”‚ └─ BGP priority: 100 (preferred) β”‚ └─ VPN: Failover (takes over if ExpressRoute fails) └─ BGP priority: 200 (backup only) Result: β”œβ”€ Normal: All traffic goes through ExpressRoute β”œβ”€ If ExpressRoute circuit fails: Automatically uses VPN βœ“ β”œβ”€ Keeps services running during maintenance/outages βœ“ └─ High availability achieved (minimal downtime) Configuration: BGP Local Preference / Priority settings on-prem └─ Advertise 10.0.0.0/16 via ExpressRoute with lower metric └─ Advertise 10.0.0.0/16 via VPN with higher metric └─ On-prem routers prefer lower metric (ExpressRoute) └─ If ExpressRoute fails, use VPN (higher metric wins)

Common Mistakes (What NOT to Do)

❌ Mistake 1: Choosing VPN for Production High-Traffic

Wrong

Production database (500 GB/month traffic): β”œβ”€ Manager says: "VPN is cheaper, let's use that" β”œβ”€ VPN bandwidth: 1.25 Gbps β”œβ”€ Actual usage: 500 GB/month = 1.5 Gbps sustained β”œβ”€ Result: Bottleneck, slow queries, timeouts βœ—

Fix

Use ExpressRoute for production: β”œβ”€ Bandwidth: 10+ Gbps available β”œβ”€ Latency: Consistent (~5ms) β”œβ”€ Throughput: Can handle 500 GB/month easily βœ“ └─ Worth the extra cost for reliability βœ“

Why it fails: VPN has bandwidth limits, not suitable for heavy production.

❌ Mistake 2: Not Planning Failover

Wrong

ExpressRoute circuit fails (provider maintenance): β”œβ”€ No VPN backup configured β”œβ”€ On-premises can't reach Azure βœ— β”œβ”€ Production services down βœ— β”œβ”€ SLA breach, customers affected βœ—

Fix

Configure redundancy: β”œβ”€ Primary: ExpressRoute (low latency) β”œβ”€ Secondary: VPN (backup) β”œβ”€ BGP preference: ExpressRoute preferred └─ On circuit failure: BGP switches to VPN automatically βœ“

Why it fails: Single point of failure.

❌ Mistake 3: Poor Routing Configuration

Wrong

On-premises routes: └─ Default route (0.0.0.0/0) β†’ VPN to Azure Result: ALL traffic to internet goes through Azure VPN βœ— β”œβ”€ Accessing external websites slow β”œβ”€ Azure gateway becomes bottleneck └─ Expensive bandwidth usage

Fix

Be specific: β”œβ”€ Route 10.0.0.0/16 β†’ VPN (only Azure) β”œβ”€ Route 0.0.0.0/0 β†’ Local internet (for web, email, etc.) └─ Result: Only Azure traffic uses VPN, internet traffic local βœ“

Why it fails: Routing all traffic through the hybrid link creates a bottleneck and wastes bandwidth.

Connectivity Checklist

β–‘ Choose technology (VPN vs. ExpressRoute) └─ VPN: Quick setup, lower cost └─ ExpressRoute: Higher bandwidth, production-grade β–‘ For VPN: β”œβ”€ VPN Gateway created in Azure VNet β”œβ”€ VPN Gateway configured on on-premises router β”œβ”€ Pre-shared key configured on both sides β”œβ”€ Routes configured (what traffic goes through VPN) └─ Connection tested (ping on-prem from Azure) βœ“ β–‘ For ExpressRoute: β”œβ”€ Order circuit from provider β”œβ”€ Wait for provisioning (2-4 weeks) β”œβ”€ Provider key received β”œβ”€ ExpressRoute gateway created in Azure β”œβ”€ BGP peers configured on both sides └─ Routes converged (on-prem routes visible in Azure) βœ“ β–‘ For both: β”œβ”€ Routing configured on both sides β”œβ”€ NSG rules allow traffic (security groups still apply) β”œβ”€ Firewall rules allow traffic (if firewalls present) └─ Performance tested (latency, bandwidth acceptable) βœ“ β–‘ For redundancy: β”œβ”€ Both VPN and ExpressRoute configured β”œβ”€ BGP priorities set (prefer one, failover to other) β”œβ”€ Failover tested (disconnect primary, verify backup works) └─ Alerts configured (notify when primary fails) βœ“

How This Connects to Other Topics

Related to Module 01 (Identity & Governance)

  • RBAC: Only network admins can configure VPN/ExpressRoute gateways

Related to Module 02 (Storage)

  • Storage Access: On-prem servers reach Azure Storage via VPN/ExpressRoute

Related to Module 04 (Networking)

  • VNet Peering: Hub VNet with gateway can serve multiple spokes

Related to Module 05 (Monitor)

  • Monitor Hybrid Connectivity: Monitor VPN/ExpressRoute metrics

See It In Action

Associated labs:

Suggested learning sequence:

  1. βœ… Read VNets & Subnets
  2. βœ… Read Routing Fundamentals
  3. βœ… Read VNet Peering
  4. βœ… Read this doc (VPN & ExpressRoute)
  5. βœ… Work through Lab 16 (hands-on VPN setup)
  6. ➑️ Read Private Endpoints & Service Endpoints

Key Takeaways

πŸ’‘ Summary
  • VPN = encrypted tunnel over internet (quick, cheaper, limited bandwidth)
  • ExpressRoute = dedicated private circuit (better performance, higher cost)
  • VPN best for: Non-critical, temporary, low-bandwidth connections
  • ExpressRoute best for: Production, high-throughput, mission-critical
  • Failover: Configure both VPN and ExpressRoute for redundancy
  • BGP routing: Automatic failover when primary fails
  • Routing specificity: Route only Azure traffic through VPN/ExpressRoute
  • NSG/Firewall rules still apply on both sides of the connection

Next Steps

  1. Learn: Read this doc (you're here)
  2. Decide: Which fits your scenarioβ€”VPN or ExpressRoute?
  3. Plan: Document on-premises IP ranges and Azure VNet ranges
  4. Practice: Lab 16: Configure VPN Gateway
  5. Advance: Set up dual connectivity with VPN + ExpressRoute
  6. Secure: Read Private Endpoints & Service Endpoints