0

I am using the Azure app service with SPA (Angular). I need to have maintenance mode (during maintenance, application redirects/opens maintenance page) for my application. Unfortunately, I cannot use slots, as I am using msal which requires application URL, to be fed as redirect URL for msal settings and each slot has its own URL. So code will not work post swapping of slots.

Is there any other way to have a maintenance mode for App Service?

Foramkumar Parekh
  • 411
  • 1
  • 6
  • 20

1 Answers1

0
  • You can set the maintenance page in multiple ways.
  • Create web.config file if you don't have and Put it in /public It will then be copied over to /dist during build.
  • I have created the config file in public folder, After running npm run build , web.config file is copied to dist folder.

enter image description here

  • To create web.config, Right click on the public folder-->Add new file, name it as web. Config and add the below mentioned code snippet and save. Create web config file in angular
  • Go to Azure portal, your Web App =>Advanced Tools=>KUDU - Debug Console =>CMD => site=>wwwroot , check if web.config file exists or not.
  • Create one html file with the content which you want to show.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<h1 style="color:Red;text-align:center">SITE UNDER MAINTENANCE</h1>
</body>
</html>

Option 1:

  • In web.config=>system.web, add the below snippet.
<system.web>
    <trace enabled="false" />
    <customErrors mode="On" defaultRedirect="yourhtmlpagename.html">   
    </customErrors>
</system.web>

Option2:

In web.config=> system.webServer tag ,add the below snippet.

 <system.webServer>
  <defaultDocument>
      <files>
        <clear/>
        <add value="yourhtmlpagename.html"/>
      </files>
  </defaultDocument>
<system.webServer>  

After adding the web.config file, app has to be re- published.

Option3:

  • In Azure portal = >Your Web App=>Configuration=>Default Documents

Click on New Document and add your html file name -yourhtmlpagename.html.

enter image description here

Restart the App ,access the URL and check once.