Private Endpoints & Service Endpoints

Secure access to Azure PaaS services from your VNet โ€” without exposing them to the internet
๐ŸŸก Intermediate โฑ 15 Minutes ๐Ÿ“˜ AZ-104 ยท Module 04
Why This Matters

You've locked down your VNets with NSGs and routing. But what about Azure services like Azure Storage or SQL Database? By default, they have public endpoints accessible from anywhere. Private Endpoints and Service Endpoints let you access Azure services securely from your VNet without exposing them to the internet.

Before You Start

PrerequisitesVNets & Subnets, Network Security Groups
Time to understand15 minutes
Difficulty๐ŸŸก Intermediate (builds on VNets and NSGs)
What you'll learnPrivate Endpoints vs. Service Endpoints, when to use each, how they work

The Simple Idea: The Problem

By default, Azure PaaS services are public. A VM in your VNet that needs to reach Azure SQL Database will, by default, route over the internet to the service's public endpoint.

That means traffic is visible on the internet (bad for security) and creates potential for man-in-the-middle attacks.

Goal: Access SQL from a VM without exposing it to the internet.

Your VNet (10.0.0.0/16) โ””โ”€โ”€ VM-A (10.0.1.5) wants to use Azure SQL Database โ””โ”€ Default: SQL has public endpoint (database.database.windows.net) โ””โ”€ Traffic: 10.0.1.5 โ†’ Internet โ†’ SQL public endpoint โœ— โ””โ”€ Traffic visible on internet (bad for security) โ””โ”€ Potential for man-in-the-middle attacks Goal: Access SQL from VM without exposing it to internet

Two Solutions

SolutionHowSecurityCost
Service EndpointDirect route to service (remains public)Good (routes through Azure backbone)Free
Private EndpointPrivate IP in your VNetExcellent (no internet exposure)Paid (~$1/month)

Solution 1: Service Endpoints

What Is a Service Endpoint?

Service Endpoint = Direct route from your VNet to an Azure service, using Azure's internal backbone (not the internet).

Real-World Analogy: Private Warehouse Door

Azure SQL Database is like a public building with multiple doors. The main entrance (public endpoint) is reachable by anyone from the internet โ€” insecure. The special warehouse door (service endpoint) is only accessible from authorized VNets, via a direct route through Azure's internal network โ€” more secure.

Azure SQL Database (Public building with multiple doors) โ”œโ”€โ”€ Main entrance (public endpoint) โ”‚ โ””โ”€ Anyone from internet can reach โ”‚ โ””โ”€ Insecure โœ— โ”‚ โ””โ”€โ”€ Special warehouse door (service endpoint) โ””โ”€ Only accessible from authorized VNets โ””โ”€ Direct route through Azure internal network โ””โ”€ More secure โœ“

How Service Endpoints Work

Step 1: Create Service Endpoint

Subnet โ†’ Service Endpoints โ†’ Select "Microsoft.Storage" โ””โ”€ Azure configures automatic route

Step 2: System Route Created

Subnet's routing table now has: Destination: Storage endpoint Next Hop: Service Endpoint (Microsoft backbone)

Step 3: Traffic Flows Securely

VM-A (10.0.1.5) โ†’ Storage service โ””โ”€ Routing: Service Endpoint route selected โ””โ”€ Path: Direct through Azure backbone (not internet) โ””โ”€ Still travels through public internet for other traffic

Service Endpoint Configuration

Step 1: Enable Service Endpoint in VNet/Subnet

Azure Portal โ†’ VNet โ†’ Subnet โ†’ Service endpoints โ””โ”€ Select: Microsoft.Storage, Microsoft.Sql, etc.

Step 2: Add Firewall Rule to Storage

Storage Account โ†’ Firewall & Virtual Networks โ””โ”€ Add VNet and subnet โ””โ”€ Result: Only traffic from this VNet allowed

Step 3: Test

VM in subnet โ†’ Storage account (now works securely) โœ“

Service Endpoint Limitations

Service Endpoint: โ”œโ”€ โœ“ Free (no extra cost) โ”œโ”€ โœ“ Quick to set up (minutes) โ”œโ”€ โœ— Service still has public endpoint (accessible from internet if allowed) โ”œโ”€ โœ— Only works with some Azure services โ”‚ โ”œโ”€ Supported: Storage, SQL Database, Cosmos DB, Key Vault, App Service โ”‚ โ””โ”€ Not supported: Some older services โ””โ”€ โœ— No private IP (routes to service's public IP, but via Azure backbone)

Solution 2: Private Endpoints

What Is a Private Endpoint?

Private Endpoint = A private IP address in your VNet that connects to an Azure service (the service gets a private IP from your VNet's address space).

Real-World Analogy: Private Branch Location

Azure SQL Database is like a headquarters. The main office (public endpoint) is visited by anyone โ€” insecure. A private branch office inside your own building (private endpoint) can only be visited by your employees; no one from outside can reach it โ€” maximum security.

Azure SQL Database (Headquarters) โ”œโ”€โ”€ Main office (public endpoint) โ”‚ โ””โ”€ Anyone can visit โ”‚ โ””โ”€ Insecure โœ— โ”‚ โ””โ”€โ”€ Private branch office inside your building (private endpoint) โ””โ”€ Only your employees can visit (same building) โ””โ”€ No one from outside can reach it โ””โ”€ Maximum security โœ“

How Private Endpoints Work

Step 1: Create Private Endpoint

Subnet โ†’ Private Endpoints โ†’ Add โ””โ”€ Resource: Azure SQL Database โ””โ”€ VNet/Subnet: Which subnet gets the private IP?

Step 2: Private IP Created

Subnet's address space: 10.0.2.0/24 โ””โ”€ Azure assigns private IP from this range โ””โ”€ Example: 10.0.2.10 becomes the SQL Database endpoint โ””โ”€ This IP is NOT publicly accessible

Step 3: Private DNS Zone

Azure creates private DNS record: โ””โ”€ database.database.windows.net โ†’ 10.0.2.10 (private IP) โ””โ”€ VM in VNet resolves this automatically โ””โ”€ VM connects to 10.0.2.10 (private connection)

Step 4: Traffic Flows Privately

VM-A (10.0.1.5) โ†’ Private endpoint (10.0.2.10) โ””โ”€ Routing: Matches local VNet route โ””โ”€ Path: Internal VNet connection (never leaves your network) โœ“

Private Endpoint Configuration

Step 1: Create Private Endpoint

Resource Group โ†’ Private Endpoints โ†’ Create โ”œโ”€ Resource: Azure SQL Database โ”œโ”€ VNet: Your-VNet โ”œโ”€ Subnet: Your subnet (private IP will come from here) โ””โ”€ DNS: Auto-register in private DNS zone โœ“

Step 2: Firewall Configuration

Storage Account โ†’ Firewall & Virtual Networks โ”œโ”€ Default action: Deny (block all public access) โ””โ”€ Private Endpoints: Auto-allowed (doesn't need rule)

Step 3: Test

VM in VNet โ†’ Can reach storage via private endpoint Internet โ†’ Cannot reach storage (completely private) โœ“

Comparison: Service Endpoint vs. Private Endpoint

AspectService EndpointPrivate Endpoint
Private IP in VNetโŒ No (routes to service's public IP)โœ… Yes (service gets IP from your subnet)
Accessible from internetโš ๏ธ Yes (if firewall allows)โŒ No (completely private)
CostFree~$1/month per endpoint
Setup timeFast (minutes)Moderate (10-15 min)
Supported servicesLimited setBroader support
DNSPublic DNS (service.region.azure.com)Private DNS zone
Bandwidth costNo extra chargeNo extra charge
Best forQuick, low-risk internal accessProduction, high-security

Decision Tree

Need to access Azure PaaS service securely? โ”‚ โ”œโ”€ VPN/ExpressRoute connected? โ”‚ โ”‚ โ”‚ โ”œโ”€ NO โ†’ Use Service Endpoint (simplest, free) โ”‚ โ”‚ โ””โ”€ "Secure enough" for most non-critical workloads โ”‚ โ”‚ โ”‚ โ””โ”€ YES โ†’ Can you route to service's IP via VPN? โ”‚ โ”œโ”€ NO (service doesn't support routing) โ†’ Service Endpoint โ”‚ โ””โ”€ YES โ†’ Choose: โ”‚ โ”œโ”€ Quick/Free: Service Endpoint โœ“ โ”‚ โ”œโ”€ Secure: Private Endpoint โœ“ โ”‚ โ””โ”€ Both: Set up Private Endpoint for production โ”‚ โ””โ”€ Need maximum security? โ””โ”€ YES โ†’ Use Private Endpoint โœ“ โ””โ”€ Service completely hidden from internet

Worked Example: Real Scenario

The Scenario

TechCorp has:

  • Azure VNet: 10.0.0.0/16
  • Dev Subnet: 10.0.1.0/24 (development VMs)
  • Production Subnet: 10.0.2.0/24 (production VMs)
  • Azure Storage Account for application data
  • Azure SQL Database for app data

Goal: Access both securely from VMs without exposing to internet.

Phase 1: Service Endpoints for Development

Dev environment (not critical): โ”œโ”€ Create Service Endpoints on Dev Subnet โ”‚ โ”œโ”€ Microsoft.Storage โ”‚ โ”œโ”€ Microsoft.Sql โ”‚ โ””โ”€ Configuration time: 5 minutes โ”‚ โ”œโ”€ Storage Account Firewall โ”‚ โ””โ”€ Add Dev VNet/Subnet as allowed โ”‚ โ”œโ”€ SQL Database Firewall โ”‚ โ””โ”€ Add Dev VNet/Subnet as allowed โ”‚ โ””โ”€ Result: โ”œโ”€ Dev VMs can access Storage and SQL โ”œโ”€ Traffic routes through Azure backbone โ”œโ”€ Cost: $0 (free) โ””โ”€ Security: Good (internal routing) โœ“

Phase 2: Private Endpoints for Production

Production environment (critical): โ”œโ”€ Create Private Endpoint 1 (Storage) โ”‚ โ”œโ”€ Resource: Storage Account โ”‚ โ”œโ”€ VNet: Your-VNet โ”‚ โ”œโ”€ Subnet: Prod Subnet (10.0.2.0/24) โ”‚ โ”œโ”€ Private DNS zone: Auto-created โ”‚ โ””โ”€ Result: Storage has private IP in subnet โ”‚ โ”œโ”€ Create Private Endpoint 2 (SQL) โ”‚ โ”œโ”€ Resource: SQL Database โ”‚ โ”œโ”€ VNet: Your-VNet โ”‚ โ”œโ”€ Subnet: Prod Subnet (10.0.2.0/24) โ”‚ โ”œโ”€ Private DNS zone: Auto-created โ”‚ โ””โ”€ Result: SQL has private IP in subnet โ”‚ โ”œโ”€ Firewall Configuration โ”‚ โ”œโ”€ Storage: Default deny (public), private endpoint allowed โ”‚ โ”œโ”€ SQL: Default deny (public), private endpoint allowed โ”‚ โ””โ”€ Result: No internet access possible โ”‚ โ””โ”€ Result: โ”œโ”€ Prod VMs can access Storage and SQL via private IPs โ”œโ”€ Traffic never leaves VNet (maximum security) โœ“ โ”œโ”€ Internet cannot reach these services โ”œโ”€ Cost: ~$2/month for 2 endpoints โ””โ”€ Security: Excellent (completely private) โœ“

Phase 3: Traffic Isolation

DNS Resolution: โ”œโ”€ Dev VM DNS: storage.azure.com โ†’ 40.88.100.5 (public) โ”‚ โ””โ”€ Resolution: Public IP (resolves through internet DNS) โ”‚ โ””โ”€ Prod VM DNS: storage.azure.com โ†’ 10.0.2.10 (private) โ””โ”€ Resolution: Private IP (resolves through private DNS zone) Traffic paths: โ”œโ”€ Dev VM โ†’ Storage: 10.0.1.5 โ†’ 40.88.100.5 (internet path) โ”‚ โ”œโ”€ Service Endpoint: Route directly through Azure backbone โ”‚ โ””โ”€ Firewall allows only from VNet โ”‚ โ””โ”€ Prod VM โ†’ Storage: 10.0.2.5 โ†’ 10.0.2.10 (VNet path) โ”œโ”€ Private Endpoint: Routes locally within VNet โ””โ”€ Never reaches internet โœ“

Common Mistakes (What NOT to Do)

โŒ Mistake 1: Relying on Service Endpoint Alone for Sensitive Data

Wrong

Service Endpoint created for SQL Database: โ”œโ”€ Routes through Azure backbone โœ“ โ”œโ”€ But SQL is still publicly accessible โ”œโ”€ Competitor discovers public IP address โ”œโ”€ Competitor uses their own VNet with Service Endpoint โ”œโ”€ Competitor can access the database โœ—

Fix

For sensitive data: โ”œโ”€ Use Private Endpoint instead โ”œโ”€ Disable public endpoint completely โ”œโ”€ Result: Only your VNet can access it โœ“

Why it fails: Service Endpoint doesn't hide the public endpoint.

โŒ Mistake 2: Private Endpoint Without Proper DNS

Wrong

Private Endpoint created for SQL (10.0.2.10): โ”œโ”€ Application code: "Connect to database.database.windows.net" โ”œโ”€ DNS resolution: Resolves to 40.88.100.5 (public IP) โ”œโ”€ Firewall: Allows only private endpoint โ”œโ”€ Result: Connection fails โœ—

Fix

Create private DNS zone: โ”œโ”€ database.database.windows.net โ†’ 10.0.2.10 โ”œโ”€ VNet linked to private DNS zone โ”œโ”€ Now: DNS resolves to 10.0.2.10 (private IP) โ”œโ”€ Connection uses private endpoint โœ“

Why it fails: DNS resolves to public IP, but firewall blocks it.

โŒ Mistake 3: Creating Private Endpoint in Wrong Subnet

Wrong

Prod Subnet: 10.0.2.0/24 (prod workloads) Dev Subnet: 10.0.1.0/24 (dev workloads) Create Private Endpoint in Subnet 10.0.1.0/24: โ”œโ”€ Prod workloads in 10.0.2.0/24 try to access database โ”œโ”€ DNS: Resolves to private endpoint IP (10.0.1.10) โ”œโ”€ Routing: 10.0.2.5 โ†’ 10.0.1.10 (different subnet) โ”œโ”€ Works but not optimal โš ๏ธ โ””โ”€ Better: Private endpoint in same subnet as clients

Fix

Create Private Endpoint in prod subnet: โ”œโ”€ Private Endpoint IP: 10.0.2.10 (same subnet as clients) โ”œโ”€ Prod workload (10.0.2.5) โ†’ 10.0.2.10 (local) โ””โ”€ Lower latency, cleaner routing โœ“

Why it fails: Not a complete failure, but adds latency and complexity.

Service Endpoint vs. Private Endpoint Checklist

Choosing between them: โ–ก For development/non-critical: โ”œโ”€ Service Endpoint usually sufficient โ”œโ”€ Lower cost (free) โ”œโ”€ Quick to set up โ””โ”€ Good balance of security and simplicity โ–ก For production/sensitive data: โ”œโ”€ Use Private Endpoint โ”œโ”€ Highest security (private IP) โ”œโ”€ Public endpoint can be completely disabled โ””โ”€ Worth the small monthly cost โ–ก Hybrid approach: โ”œโ”€ Service Endpoints: External/non-critical services โ”œโ”€ Private Endpoints: Internal/sensitive services โ””โ”€ Both: Some organizations use both for defense-in-depth โ–ก If using Private Endpoint: โ”œโ”€ Create private DNS zone (auto-done) โ”œโ”€ Link DNS zone to VNet โ”œโ”€ Disable public endpoint on storage โ””โ”€ Test: Confirm private endpoint works, public fails โœ“ โ–ก If using Service Endpoint: โ”œโ”€ Enable on subnet(s) where workloads exist โ”œโ”€ Add VNet/subnet to storage firewall โ”œโ”€ Storage still has public endpoint โ””โ”€ Consider: Is this sufficient for security requirements? โœ“

How This Connects to Other Topics

Related to Module 01 (Identity & Governance)

  • RBAC: Only admins can create/manage Private Endpoints

Related to Module 02 (Storage)

  • Storage Security: Private Endpoints secure storage access
  • Storage Firewall: Works with both Service and Private Endpoints

Related to Module 03 (Compute)

  • VM Access to Services: VMs use Private/Service Endpoints to reach PaaS

Related to Module 05 (Monitor)

  • Monitor Endpoint: Track Private Endpoint connections

See It In Action

Associated labs:

Suggested learning sequence:

  1. โœ… Read VNets & Subnets
  2. โœ… Read Network Security Groups
  3. โœ… Read VPN & ExpressRoute
  4. โœ… Read this doc (Private Endpoints & Service Endpoints)
  5. โœ… Work through Lab 17 (Service Endpoints hands-on)
  6. โœ… Work through Lab 18 (Private Endpoints hands-on)

Key Takeaways

๐Ÿ’ก Summary
  • Service Endpoint = free route to service (good, not perfect)
  • Private Endpoint = private IP in your VNet (best security)
  • Service Endpoint: Suitable for non-critical, internal-only traffic
  • Private Endpoint: For sensitive data, production workloads
  • Private DNS zone: Required for Private Endpoints to work seamlessly
  • Firewall integration: Both work with storage/service firewalls
  • Public endpoint: Can be disabled entirely with Private Endpoints
  • Cost: Service Endpoint free, Private Endpoint ~$1/month

Next Steps

  1. Learn: Read this doc (you're here)
  2. Understand: When to use each (decision tree above)
  3. Practice: Lab 17: Service Endpoints
  4. Practice: Lab 18: Private Endpoints
  5. Secure: Disable public endpoints for sensitive services
  6. Monitor: Track endpoint usage and security