I have an Azure app service that is running on 2 instances. I tried the Advanced Application restart and put in a restart delay of 90 seconds or more.
When one of the instances restarts, client requests still seem to be sent to the restarting instance. I see requests taking over 60 seconds to return.
I would have thought that when one of the instances restarts it would not be available until it was ready to process requests.
If I need to restart one of the instances, how can I make sure that there is no interruption to anyone?
ASP.Net 4.6.1
Use the AppInit feature :
With the AppInit feature, a new web app instances are added into the rotation, we ensure that the Application Initialization module reports that the site is fully warmed up before sending it a request from the frontend. To use the feature, add an applicationInitialization section to your web.config like so:
<system.webServer>
<applicationInitialization remapManagedRequestsTo="/Content/warmup.html">
<add initializationPage="/api/values/100" />
</applicationInitialization>
</system.webServer>
You can have multiple initialization pages, and the AppInit module will ensure that all of them return 200 before declaring the site officially warmed up. Meanwhile, you can (optionally) use the remapManagedRequestsTo attribute to have a friendly page showing that the site is still warming up. Thanks to the AppInit feature, this page will not be visible to customers while adding new instances into rotation, however if a process crashes for whatever reason and enters AppInit again, it will come into play.
Application Initialization module is installed by default for Azure Web Apps. You can directly configure it from either your web.config file or through apphost.config XDT. Just stick something like above in a web.config in the root of your web app.
You can follow the below links also for more information. https://learn.microsoft.com/en-us/iis/configuration/system.webserver/applicationinitialization/#configuration
https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/