Configure routing rules

3.2 Azure Application Gateway

📘Microsoft Azure Networking Solutions (AZ-700)


Routing rules in Azure Application Gateway define how incoming web traffic is directed to backend resources. They are the main mechanism that ensures requests reach the correct servers, apps, or services.

Think of routing rules as instructions inside the gateway telling it: “If a request comes in like this, send it to that server group.”


1. Components Involved in Routing Rules

Before configuring routing rules, you must know the components that work together:

  1. Listener
    • This listens for incoming traffic on a specific IP, port, or protocol.
    • Example: A listener can monitor https://portal.contoso.com on port 443.
  2. Backend Pool
    • A group of servers or services that will handle the traffic.
    • Example: web-servers-prod containing 3 virtual machines (VMs).
  3. HTTP Settings
    • Define how the Application Gateway communicates with the backend pool.
    • Settings include: protocol (HTTP or HTTPS), port, cookie-based affinity, connection draining, etc.
    • Example: Route requests to backend on port 80 or 443 with HTTPS.
  4. Routing Rule
    • Combines a listener, backend pool, and HTTP settings.
    • Specifies the conditions to match traffic and send it to the right backend.

2. Types of Routing Rules

Azure Application Gateway supports two main types of routing rules:

  1. Basic Rule
    • Directly links a listener to a backend pool.
    • No path-based logic; all traffic hitting this listener goes to the same backend.
    • Example:
      • Listener: https://portal.contoso.com
      • Backend Pool: web-servers-prod
      • All requests are sent to the same servers.
  2. Path-Based Rule
    • Routes traffic based on the URL path.
    • Useful when different parts of your application live on different backend pools.
    • Example:
      • Requests to https://portal.contoso.com/images → go to image-servers backend pool.
      • Requests to https://portal.contoso.com/api → go to api-servers backend pool.

3. How to Configure a Routing Rule

Here’s a step-by-step process for exam purposes:

  1. Create or identify a listener
    • Decide if it’s HTTP or HTTPS.
    • Assign the hostname (optional) and port.
    • For HTTPS, you need an SSL certificate.
  2. Create or select a backend pool
    • Add servers, IPs, or even other Azure resources like Azure App Services.
  3. Define HTTP settings
    • Select protocol (HTTP/HTTPS), backend port, and optional features:
      • Cookie-based affinity – keeps a user session on the same backend server.
      • Connection draining – gracefully remove a server from a pool for maintenance.
  4. Create the routing rule
    • Choose Basic or Path-Based type.
    • Link the rule to a listener, backend pool, and HTTP settings.
    • For path-based rules, define paths and assign backend pools for each.
  5. Test the configuration
    • Ensure requests route correctly to the intended backend pool.
    • Use Azure Monitor or logging to check traffic flow.

4. Exam Tips for Routing Rules

  • Remember the four main components: Listener → Backend Pool → HTTP Settings → Routing Rule.
  • Path-based rules are required for multiple backend pools behind the same listener.
  • Listener is always required; without it, traffic won’t reach the gateway.
  • Routing rules can be multi-site or single-site:
    • Single-site: One domain, one listener.
    • Multi-site: Multiple domains using the same gateway, each with its own routing rule.

5. Real IT Environment Example

Imagine a company has a web portal and API:

  • portal.contoso.com → Web portal hosted on VMs (web-servers-prod)
  • portal.contoso.com/api → API hosted on Azure App Service (api-servers)

Configuration:

ComponentConfiguration
Listenerhttps://portal.contoso.com on port 443
Backend Pool 1web-servers-prod for web portal
Backend Pool 2api-servers for API requests
Routing RulePath-based: /api → Backend Pool 2, / → Backend Pool 1
HTTP SettingsHTTPS, port 443, cookie-based affinity off

Outcome: Requests automatically go to the correct backend based on the URL path.


Key Points to Remember for the Exam

  • Routing rules link listeners to backend pools via HTTP settings.
  • Two types: Basic and Path-based.
  • Listeners are essential, and path-based rules allow different paths to reach different backends.
  • Always check HTTP settings, as they control the connection behavior to backends.
  • Multi-site routing allows handling multiple domains on the same Application Gateway.
Buy Me a Coffee