This post has been republished via RSS; it originally appeared at: Azure App Service articles.
Note: This article applies to Windows App Service Plan only as both Local Cache and Swap with Preview are not available for Linux App Service Plan's. Additionally, Slot Swap feature is available for sites running in Standard or higher pricing tiers.
Scenario: There is a site in production which is running on 2 instances and has Local Cache enabled. We need to deploy new content to it with minimal downtime.
- The App Service Plan is using Windows OS.
- The production slot has Local Cache enabled.
- The staging slot where the new content/code is being deployed doesn't have Local Cache enabled.
Steps to deploy:
- If not already created, then create a new staging slot.
- Deploy the code to the staging slot.
- Navigate to Deployment slots and click on Swap.
- Select the Source and the Target slots and select the checkbox "Perform swap with preview".
- You can review the changes that will be applied and then click on Start Swap button. This will initiate Phase one of the swap.
- This will perform a restart of the application so that the prod settings can be applied to the application and also to initialize Local Cache. This completes Phase one of the swap.
- Once the app has been restarted, browse the slot to review the changes that were made to the new code base for this application.
- In order to proceed with Phase two, we need to wait for Local cache initialization to complete. Follow the below steps to determine if the Local Cache has been initialized.
- Browse to the KUDU Console of the slot.
- Click on Process Explorer menu.
- You will see a list of process. Right click the process that doesn't have the SCM tag against it and click on properties.
- Click on Environment variables and find environment variable WEBSITE_LOCALCACHE_READY. If the value of this variable is set to TRUE, then Local Cache has been initialized, if it is False, then Local Cache initialization is still in progress.
NOTE: You can call the KUDU api to automate the above process. Review the documentation here.
- Once the process environment variable WEBSITE_LOCALCACHE_READY is set to TRUE, browse the slot and if everything looks good, set the Swap action to Complete Swap and click on Complete Swap button. If you need to revert the change, then set the Swap action to Cancel Swap and click on Cancel Swap button.
- The Complete Swap will now promote the staging slot to production. Since its already running against Local Cache, the site will not encounter additional restarts and will be serving production traffic.