Search code examples
azureexpressazure-web-app-servicecustom-error-pages

Are custom error pages possible on Azure App Service slots?


I'm trying to build a "maintenance mode" screen for Azure App Services running a single-page Vue app. Is this possible without Application Gateway?

Background

  • Azure App Service instance
  • Runs a Node Express server on startup
  • Express serves up a single page app
  • All data is fed into the SPA via an API
  • When the API undergoes maintenance I need a way to tell the front-end
  • I'd prefer not to ask the API if it's available for each page view

Ideas and things we've tried

I know Azure Application Gateway can serve up custom error pages, but we're currently not using this service and might have some legal/data privacy issues (it's a healthcare tool) with its data caching requirements.

I added a web.config file to the wwwroot on the service slot as an attempt to catch errors and redirect but it seems to have no impact. This is what I expected since Express should be handling routing and errors (which it does).

Asure has the ability to "stop a slot". Is there any way to customize the page that's displayed?

Other web searches show that custom errors were requested at one point, but the Azure feature request page produces a very beautiful 404 page (oh the irony).

Is there a way to customize the stopped and/or server error pages in Azure? Are there other commonly accepted ways of solving a problem like this?


Solution

  • Custom Error page is only available by using the Application Gateway. This feature is not available Without Application Gateway. If you want this feature please add your feed back/Feature request here

    You can catch the http errors only by using web.config in wwwroot directory by adding below code

    < httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
    < remove statusCode="404" subStatusCode="-1" />
    < error statusCode="404" path="/public/CustomError.html" responseMode="ExecuteURL" />
    < /httpErrors>
    

    On above snippet of code can redirect to the CustomError.html if any html error occurred. Refer here