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.
Something as below:
Normal traffic:
- www.fabrikam.com -----> goes to backend uninterrupted.
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.
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.