Hello @Ni, Yibo ,
Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.
I understand that you would like to know if you can customize a unique response schema for 4xx and 5xx errors on your Application gateway.
Is there a better way matching my requirement to handle all responses?
As of today, the only way to create a custom error page in Application gateway is to ensure the error page should be in *.htm
or *.html
extension type. You need to provide the URL for the error page for the configuration. There is no other way to handle the responses.
We usually get a response through an interface call rather than a browser. Can I set customer parameters to response header or body?
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. Any externally referenced resources (such as images, JavaScript, and CSS files) are fetched directly by the client.
This is not possible through an interface call.
Also, HTTP headers and URL 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
So, when you have a custom error page configured in your Application gateway, you cannot configure header rewrites. This is a limitation.
If you wish you may also leave your feedback in the below forum requesting this feature. All the feedback you share in these forums will be monitored and reviewed by the Microsoft engineering teams responsible for building Azure.
https://feedback.azure.com/d365community/forum/8ae9bf04-8326-ec11-b6e6-000d3a4f0789
Kindly let us know if the above helps or you need further assistance on this issue.
Please don’t forget to "Accept the answer" wherever the information provided helps you, this can be beneficial to other community members.