404 response code caused by App Services – AlwaysOn feature
In this post, Sr. Consultant Adel Ghabboun shows how to optimize Azure App Service against cold starts using AlwaysOn.
- Azure App service with AlwaysOn feature = True (See below screenshot)
- Traffic Manager and Application Gateway are used, which relay on health probes to determine the availability and health of the App Service
- Application Insights for monitoring
- App Service Always On also generate periodic (every 5min) probes to app instances and causing failed requests with error 404, and this can be found in Application Insights as below
This can be fixed by rewriting the Always on path. After a cold start of your application, AlwaysOn will send a request to the ROOT of your application “/”. Whatever file is delivered when a request is made to / is the one which will be warmed up, which will fail because the root doesn’t exist.
If you wanted AlwaysOn to warmup a specific page instead of the root, then you can implement this URL Rewrite rule.
Please refer here for more details.
Something to note here that if you are already using Azure Traffic Manager service with a health probe periodically pinging the site/path, AlwaysOn would be redundant as the web app will be kept warm by the health probes.