Azure App Service - Deployment slot warm-up

Fabio Henrique Micai Gonzaga 0 Reputation points Microsoft Employee
2024-04-17T17:19:10.6766667+00:00

I'm deploying a .net core 6 web app to a staging deployment slot using ARM template. The auto swap is disabled. This web app only accepts https connections (configured on azure, not on my code).

How can I warm-up this staging slot?

Do I have to call the endpoint myself or can this be done automatically just like it happens when we use auto swap?

Thanks,

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,901 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Claudia Dos Santos Haz (CONCENTRIX CORPORATION) 695 Reputation points Microsoft Vendor
    2024-04-19T14:25:43.5166667+00:00

    Hi Fabio Henrique Micai Gonzaga •,

    Thank you for reaching out to Microsoft Q&A forum!

    When deploying a .NET Core 6 web app to a staging deployment slot using an ARM template, warming up the staging slot is essential to ensure smooth transitions during deployment. While auto swap typically handles this automatically, when auto swap is disabled, you can follow these steps to warm up your staging slot:

    Manual Warm-Up:

    You can manually warm up your staging slot by calling the endpoint yourself. This involves sending requests to the staging slot’s URL to initialize the application and load any necessary resources.
    
       To do this, create a script or use a tool (such as **`curl`** or **`Invoke-WebRequest`** in PowerShell) to send HTTP requests to your staging slot’s URL. These requests should simulate typical user interactions (e.g., accessing different pages, invoking APIs, etc.).
      
          Keep in mind that this approach requires manual intervention and monitoring.
         
         **Automated Warm-Up (Recommended)**:
         
             While auto swap handles warm-up during production slot swaps, you can achieve similar behavior for your staging slot by automating the process.
            
                Consider implementing an Azure Function or Logic App that periodically sends requests to your staging slot’s URL. You can schedule these requests to occur at specific intervals (e.g., every few minutes).
               
                   The requests should hit various endpoints within your application to ensure that all components are initialized. For example, you can request the home page, API endpoints, and any other critical routes.
                  
                      By automating this warm-up process, you ensure that your staging slot remains responsive and ready for traffic.
                     
                     **Additional Considerations**:
                     
                         If your web app is hosted in IIS (which is likely the case), set the following configurations:
                        
                               Set the **start mode** of the app pool to **“AlwaysRunning”**.
                              
                                     Set the **Idle time-out** to **0** to prevent the app pool from shutting down due to inactivity.
                                    
                                           Enable **preload** by setting **“preload enabled”** to **true** on the web site.
                                          
                                              These settings help keep your application warm and responsive even when there’s no incoming traffic.
                                             
    

    Remember that warm-up is crucial to minimize cold start delays and ensure optimal performance when transitioning to the staging slot. Choose the approach that best fits your deployment process and monitoring requirements1

    0 comments No comments

  2. brtrach-MSFT 15,256 Reputation points Microsoft Employee
    2024-04-23T04:48:45.15+00:00

    @Fabio Henrique Micai Gonzaga Claudia's answer is very comprehensive and covers all the necessary steps for warming up a staging deployment slot in Azure App Service. I would only add that it's important to monitor the warm-up process to ensure that it's working as expected. You can use Azure Application Insights or other monitoring tools to track the performance of your web app during the warm-up process and identify any issues that may arise. Additionally, you can consider setting up alerts to notify you if the warm-up process fails or if there are any performance issues with your web app.

    Please let us know if Claudia's answer was helpful by accepting it as the answer. Otherwise reply here so we can assist you further.

    0 comments No comments