Whenever we want to do any maintenance in our container Apps we want our visitors to see the maintenance page instead of the actual error. by using the rewite

murugan, balaganesh 0 Reputation points
2024-04-18T11:43:19.68+00:00

Whenever we want to do any maintenance in our container Apps we want our visitors to see the maintenance page instead of the actual error. There should be a mechanism (script) to turn this on and off when maintenance starts and over.

For the maintenance we have 3 scenarios and we need 3 path based rules so that we can redirect our users to the maintenance page depending on that scenario. And we can turn this on and off by the script instead of manually from the portal.

How to do it ?

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
960 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,900 questions
{count} votes

1 answer

Sort by: Most helpful
  1. GitaraniSharma-MSFT 47,421 Reputation points Microsoft Employee
    2024-04-18T13:56:24.0833333+00:00

    Hello @murugan, balaganesh ,

    I understand that you would like to setup and show your visitors a custom maintenance page instead of the actual error by using the Application gateway rewrite rules when you do any maintenance in your container Apps.

    Application gateway supports creation of customized error pages instead of displaying default ones and they can be defined/configured at a Global or Listener level.

    But these custom error pages are displayed for response codes generated by Application Gateway. If an error originates from the backend server, it is passed along unmodified to the client.

    Refer: https://learn.microsoft.com/en-us/azure/application-gateway/custom-error

    Additionally, there is a limitation on the Application gateway rewrite rules as below:

    • Rewrites aren't supported when the application gateway is configured to redirect the requests or to show a custom error page.

    Refer: https://learn.microsoft.com/en-us/azure/application-gateway/rewrite-http-headers-url#limitations

    Also, there is no "on and off" feature for this. After you specify an error page in your application gateway's configuration, your gateway verifies the connectivity to the HTML page over the internet. It then downloads the file on its local cache. When a client faces an error, your application gateway returns a response code and that HTML page.

    So, my suggestion would be to run a PowerShell command to update the URL of your application using rewrite rules whenever there is a maintenance.

    Refer: https://learn.microsoft.com/en-us/powershell/module/az.network/new-azapplicationgatewayrewriteruleset?view=azps-11.5.0

    https://learn.microsoft.com/en-us/powershell/module/az.network/new-azapplicationgatewayrewriteruleurlconfiguration?view=azps-11.5.0

    Something as below:

    Normal traffic:

    During maintenance:

    • www.fabrikam.com -----> gets redirected to a particular page, based on URL path.
    • For this we add the URL path using rewrite rules - "www.fabrikam.com" to "www.fabrikam.com/maintenance.png"

    Post maintenance,

    • We remove the rewrite rule.

    Refer: https://learn.microsoft.com/en-us/azure/application-gateway/rewrite-http-headers-url#rewrite-types-supported

    Kindly let us know if the above helps or you need further assistance on this issue.


    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments