Routing approaches
- Path-based routing (URL path)
- Multi-site routing (hostname / domain)
Path-based routing and multi-site routing both use Layer 7 features to enable granular traffic management and a better user experience by sending requests to the backend best suited to serve them.
Path-based routing
Path-based routing allows the Application Gateway to inspect the request URL path and forward requests to a specific backend pool based on path patterns. Typical examples:
*/images/*→ image server pool optimized for static content*/video/*→ video server pool for streaming and large media
https://kodekloud.com→ learning backend poolhttps://kodekloudlabs.com→ lab backend pool

Demo: Deploying an Application Gateway in the Azure portal
This demo uses a prepared deployment script that creates several VMs representing backend pools:- Red pool:
red-01,red-02(default) - Blue pool:
blue-01,blue-02(served at/blue) - Green pool:
green-01,green-02(served at/green) - Jumpbox for SSH access to the private VMs
- Default (root path) → red servers
- Paths containing
/blue→ blue servers - Paths containing
/green→ green servers

Create the Application Gateway (portal walkthrough)
Follow these high-level steps in the Azure portal to create and configure the Application Gateway for the demo:- Start Create > Application Gateway in the Azure portal (portal.azure.com).
- Select subscription, resource group and provide a name for the gateway.
- Choose SKU / tier:
- Options:
Standard,Standard_v2,WAF,WAF_v2. - For this demo use
Standard_v2(supports autoscaling and improved performance). For production workloads, evaluate WAF if you require web application firewall protection.
- Options:
- Set instance count and availability zones as needed (single instance is fine for demos).
- Ensure networking: select the virtual network and a dedicated subnet for the Application Gateway.
- Configure Frontends (assign or create a Public IP for internet-facing gateways).
- Define backend pools — create a pool for each color group (red, blue, green).
- Create backend HTTP settings (protocol, port, host header override, cookie affinity as needed).
- Create a listener and routing rules:
- For path-based routing, create a basic listener and then add path-based rule entries mapping
/blue/*and/green/*to the corresponding backend pools.
- For path-based routing, create a basic listener and then add path-based rule entries mapping
/24), but in production plan subnet sizes according to scale and security requirements.
Application Gateway must be deployed into its own subnet (usually named
ApplicationGatewaySubnet). Do not place other resources in that subnet. Plan IP address capacity for your expected scale and features (v2 SKUs can reduce address needs, but still plan ahead).ApplicationGatewaySubnet was added and is selectable during gateway creation.


PIP) and set SKU and assignment method as needed.

- Rule name:
appgwcolors HTTP route - Listener name:
AppGW-colors-HTTP-listener - Frontend IP: Public
- Protocol: HTTP
- Port: 80
- Listener type: Basic (use multi-site listeners only for host-based routing)


- Add path-based rule entries such as
/blue/*and/green/*. - For each path pattern select the corresponding backend pool and backend HTTP setting.
- Save and validate the configuration; test by sending requests to the public IP or DNS name with the appropriate paths.
- Use
curlor a browser to testhttp://<public-ip-or-dns>/,http://<public-ip-or-dns>/blue/, andhttp://<public-ip-or-dns>/green/to confirm routing to the red, blue, and green pools respectively. - If backend responses are not as expected, verify backend health probes and backend HTTP settings (host header and port).
- If a VM extension failed during deployment, SSH from the jumpbox and check the web server/container on the target VM.
- Path-based routing directs traffic by URL path to specific backend pools.
- Multi-site routing directs traffic by hostname (domain) to different backend pools.
- Application Gateway requires a dedicated subnet and a frontend IP (public for internet-facing gateways).
- Configure listeners, backend HTTP settings, backend pools, and routing rules to implement the desired routing behavior.
- Azure Application Gateway documentation
- Azure Virtual Network documentation
- Create an Application Gateway in the Azure portal