How to configure a context based switch with different backend targets on Application gateway

Elango K 0 Reputation points
2023-10-27T05:52:02.93+00:00

I had a website, it had multiple context and each context had its backend servers.

How can i configure the context based switching in this.

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,014 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deepanshukatara-6769 8,060 Reputation points
    2023-10-27T06:10:22.69+00:00

    Hi , hope doing well

    To answer your question , please check below

    Configuring a context-based switch with different backend targets on an Azure Application Gateway involves several steps. Context-based switching allows you to route traffic to different backend pools based on request criteria, such as the URL path, hostname, or headers. Here's a step-by-step guide:

    Prerequisites:

    1. You should have an Azure subscription with the necessary permissions.
    2. You should have already created an Application Gateway and the backend pools you want to switch between.

    Step 1: Create Backend Pools If you haven't already created backend pools for your different services, do so. Each backend pool should correspond to a different backend service you want to route traffic to.

    Step 2: Create HTTP Settings You'll need to define HTTP settings for each backend pool if they have different requirements (e.g., different ports or custom health probes).

    Step 3: Create Multi-Site Listener

    1. Go to the Azure portal and navigate to your Application Gateway.
    2. Under "Listeners," click "Add a listener."
    3. Choose "Multi-site" as the listener type.
    4. Configure the listener with the appropriate frontend IP configuration and port.
    5. Under "Host names," specify the hostnames you want to route traffic for. You can use wildcards like *.example.com if needed.
    6. Save the listener.

    Step 4: Define Routing Rules

    1. After creating the listener, go to the "Rules" section of your Application Gateway.
    2. Click "Add a routing rule."
    3. Give your rule a name.
    4. For the listener, select the multi-site listener you created earlier.
    5. Choose a backend pool based on the criteria you want to use (e.g., hostname, path, or headers).
    6. You can create custom conditions to match the criteria you specified. For example, to match requests to a specific path, you can use the "Path-based routing" condition.
    7. Select the appropriate backend pool for each condition.
    8. Save the rule.

    Step 5: Update DNS Records You need to update your DNS records to point to the Application Gateway's public or private IP address.

    Step 6: Test the Configuration Test the configuration by sending requests to the different hostnames or paths to verify that traffic is being routed to the correct backend pools.

    Step 7: Monitor and Tune Regularly monitor your Application Gateway's performance and adjust routing rules as needed. You can also configure health probes to automatically remove unhealthy backend instances from the pools.

    This guide provides a high-level overview of the steps involved in setting up a context-based switch with different backend targets on an Azure Application Gateway. The specifics may vary based on your use case and configuration requirements.

    Please check this link --> https://learn.microsoft.com/en-us/azure/application-gateway/configuration-listeners

    Please accept answer if it has helped , Thankyou!

    0 comments No comments