In Azure Load Balancer, you saw that the load balancer relies on the source IP, source port, destination IP, destination port, and protocol for routing the traffic. Azure Load Balancer uses the five-tuple hash, three-tuple hash, or two-tuple hash for routing the traffic to the backend servers. Application Gateway is a layer 7 load balancer, so the routing mechanism is different from the one that you witnessed in the case of Azure Load Balancer.
The following are the routing methods available in Application Gateway.
Path-Based Routing
In path-based routing, Application Gateway inspects the URL paths and routes the traffic to the different backend pools. For example, you can direct the requests with the path /docs/* to the backend pool containing the documents. Similarly, all URLs containing the path /videos/* can be routed to the backend servers optimized for video streaming. In Figure 5.9, you can see how path-based routing is accomplished.

FIGURE 5.9 Path-based routing
Multisite Routing
Multisite routing or multiple site routing lets you configure more than one web application behind the same Application Gateway. In this configuration, you need to map the front-end IP address of the Application Gateway to multiple CNAMEs. For example, say the front-end IP address of the Application Gateway is 13.67.11.172 and you have two web applications, such as http://azuretales.com and http://azuretaleslabs.com. You will map the front-end IP as a CNAME to both domains. When the requests hit the Application Gateway based on the URL, it will be routed to the appropriate web application. Figure 5.10 shows how the multisite routing is done.

FIGURE 5.10 Multisite-based routing
You need to configure separate listeners to wait for each site. Each listener is attached to a different rule, by which you can route the request to the backend pool for the respective site. Now, let’s take a closer look at the configuration of Application Gateway.
Configuring Application Gateway
During the process of routing the requests from the front end to the backend, a series of components is involved. An understanding of these components is required for configuring Application Gateway. In Figure 5.11, you can see how the traffic routes from the front-end IP to the backend pool.

FIGURE 5.11 Routing of traffic from the front end to the backendNow we will discuss each of these blocks.