2x2 WorksBlog

Azure AppService returns 503 Service Unavailable

18 January, 2020 - 2 min read

One of our projects use Azure App Service Deployment Slots. We push changes through a Jenkins pipeline. Each deployment does what seems to be a standard "diff" deployment - pushing only the files that have changed in the recent build compared to what is on the AppService (I believe relying on SkipExtraFilesOnServer params for WebDeploy).

In other words, if you have a file that is only available on your AppService box the deployment push is going to leave it there.

When a deployment slot is used to swap two AppService instances when serving an app, it appears as if the underlying process Azure uses places a file called "app_offline.html" in the root directory of the AppService as it does it's thing. Once done, the file is removed (that seems to be the idea, anyways, but causes some troubles elsewhere, too).

The existence of app_offline.html in a root directory of a website seems to force an AppService to always return that file to whatever request the app is receiving. It's a shortcut method of putting your site offline for whatever reason. Definitely useful.

The glitch comes when CI/CD deployment does that "diff" deployment to preserve bandwidth/amount of files pushed to Azure and leaves unique files on the box. Occasionally, swapping a deployment slot does not succeed and in such cases, there's a chance that an app_offline.html file might be left there unintentionally.

If you keep seeing 503 Service Unavailable responses to whatever requests are issued at the AppService, chances are that the AppService has app_offline.html in the root. Remove it (open App Service Editor (Preview) > Go for your AppService in Azure portal and find the file in the left sidebar and right-click > Delete) and things should go back to normal.

Resources

1. Azure ZIP deployments