asp.net-mvcazurewarm-upazure-deployment-slots

Azure ASP.NET Warm Up and Deployment Slot


I'm using ASP.NET MVC 5 and Azure Premium app services with AlwaysRunning option set "on".

I created a deployment slot for the web app, deployed my new version, opened the slot URL and everything was fast and stable. I swapped to the production environment and after the swap operation was complete the web app was slow, like if I had deployed manually to PROD. I had to wait more than a minute to have my app working again. Based on what I read I thought the app was going to be warmed up after swapping but it didn't work out.

Why after swapping it was so slow? even pages that don't hit the DB like the authentication form.

UPDATE: After switching to a V2 plan (SSD storage) the app gets restarted in less than 2 minutes :)


Solution

  • To warm up the site during a swap, you have to configure the routes to hit. You would need something like this in web.config (link):

    <system.webServer>
      <applicationInitialization >
        <add initializationPage="/warmup-cache" hostName="appinit-warmup.azurewebsites.net"/>
      </applicationInitialization>
    </system.webServer>
    

    The app is most likely re-compiling Razor views, that's why it takes a while. You could pre-compile the Razor views, that would help tremendously (link). Also having a warm-up route like above registered that pre-populates caches would help.