Staged Deployment on Microsoft Azure Websites
Staged Deployment on Microsoft Azure Websites
When you deploy your application to Azure Websites, you can deploy to a separate deployment slot instead of the default production slot, which are actually live sites with their own hostnames. This option is available in the Standard web hosting plan. Furthermore, you can swap the sites and site configurations between two deployment slots, including the production slot. Deploying your application to a deployment slot has the following benefits:
You can validate website changes in a staging deployment slot before swapping it with the production slot.
After a swap, the slot with previously staged site now has the previous production site. If the changes swapped into the production slot are not as you expected, you can perform the same swap immediately to get your "last known good site" back.
Deploying a site to a slot first and swapping it into production ensures that all instances of the slot are warmed up before being swapped into production. This eliminates downtime when you deploy your site. The traffic redirection is seamless, and no requests are dropped as a result of swap operations.
Four deployment slots in addition to the production slot are supported for each website in the Standard plan.
Table of Contents
To Add a Deployment Slot to a Website
The website must be running in the Standard hosting plan to enable multiple deployment slots.
On the Quick Start page, or in the Quick Glance section of the Dashboard page for your website, click Add a new deployment slot.
If the website is not already in Standard mode, you will receive the message You must be in the standard mode to enable staged publishing. At this point, you have the option to select Upgrade and navigate to the Scale tab of your website before continuing.
In the Add New Deployment Slot dialog, give the slot a name, and select whether to clone website configuration from another existing deployment slot. Click the check mark to continue.
The first time you create a slot, you will only have two choices: clone configuration from the default slot in production or not at all.
After you have created several slots, you will be able to clone configuration from a slot other than the one in production:
In the list of websites, expand the mark to the left of your website name to reveal the deployment slot. It will have the website name followed by the deployment slot name.
When you click the name of the deployment site slot, a page will open with a set of tabs just like any other website. your-website-name(deployment-slot-name) will appear at the top of the portal page to remind you that you are viewing the deployment site slot.
Click the site URL in the dashboard view. Notice the the deployment slot has its own hostname and is also a live site. To limit public access to the deployment slot, see Azure Web Sites – block web access to non-production deployment slots.
There is no content. You can deploy to the slot from a different repository branch, or an altogether different repository. You can also change the slot's configuration. Use the publish profile or deployment credentials associated with the deployment slot for content updates. For example, you can publish to this slot with git.
About Configuration for Deployment Slots
When you clone configuration from another deployment slot, the cloned configuration is editable. The following lists show the configuration that will change when you swap slots.
Configuration that will change on slot swap:
- General settings
- Connection strings
- Handler mappings
- Monitoring and diagnostic settings
Configuration that will not change on slot swap:
- Publishing endpoints
- Custom Domain Names
- SSL certificates and bindings
- Scale settings
Multiple deployment slots are only available for sites in the Standard web hosting plan.
When you site has multiple slots, you cannot change the hosting plan.
A slot that you intend to swap into production needs to be configured exactly as you want to have it in production.
By default, a deployment slot will point to the same database as the production site. However, you can configure the deployment slot to point to an alternate database by changing the database connection string(s) for the deployment slot. You can then restore the original database connection string(s) on the deployment slot right before you swap it into production.
To Swap Deployment Slots
To swap deployment slots, select the deployment slot in the websites list that you want to swap and click the Swap button in the command bar.
The Swap Deployments dialog appears. The dialog lets you choose which site slot should be the source and which site should be the destination.
Click the checkmark to complete the operation. When the operation finishes, the site slots have been swapped.
To Rollback a Production Site to Staging
If any errors are identified in production after a slot swap, roll the slots back to their pre-swap states by swapping the same two slots immediately.
To Delete a Site Slot
In the command bar at the bottom of the Azure Websites portal page, click Delete. You will be given the option to delete the website and all deployment slots, or delete only the deployment slot.
Scaling is not available for non-production slots. It is only available for production slots.
Linked resource management is not supported for non-production slots.
You can still publish directly to your production slot if you wish.
By default, your deployment slots (sites) share the same resources as your production slots (sites) and run on the same VMs. If you run stress testing on a stage slot, your production environment will experience a comparable stress load.
In the Azure Preview Portal only, you can avoid this potential impact on a production slot by temporarily moving the non-production slot to a different Web Hosting Plan. Note that the test and production slots must once again share the same Web Hosting Plan before you can swap the test slot into production.
Azure PowerShell cmdlets for Site Slots
Azure PowerShell is a module that provides cmdlets to manage Azure through Windows PowerShell, including support for managing Azure Websites deployment slots.
For information on installing and configuring Azure PowerShell, and on authenticating Azure PowerShell with your Windows Azure subscription, see How to install and configure Windows Azure PowerShell.
To list the cmdlets available for Azure Websites in PowerShell, call
The Get-AzureWebsite cmdlet presents information about Azure websites for the current subscription, as in the following example.
You can create a site slot for any website in Standard mode by using the New-AzureWebsite cmdlet and specifying the names of both the site and slot. Also indicate the same region as the site for deployment slot creation, as in the following example.
New-AzureWebsite siteslotstest -Slot staging -Location "West US"
You can use the Publish-AzureWebsiteProject cmdlet for content deployment, as in the following example.
Publish-AzureWebsiteProject -Name siteslotstest -Slot staging -Package [path].zip
After content and configuration updates have been applied to the new slot, you can validate the updates by browsing to the slot using the Show-AzureWebsite cmdlet, as in the following example.
Show-AzureWebsite -Name siteslotstest -Slot staging
The Switch-AzureWebsiteSlot cmdlet can perform a swap operation to make the updated deployment slot the production site, as in the following example. The production site will not experience any down time, nor will it undergo a cold start.
Switch-AzureWebsiteSlot -Name siteslotstest
If a deployment slot is no longer needed, it can be deleted by using the Remove-AzureWebsite cmdlet, as in the following example.
Remove-AzureWebsite -Name siteslotstest -Slot staging
Azure Cross-Platform Command-Line Interface (xplat-cli) commands for Site Slots
The Azure Cross-Platform Command-Line Interface (xplat-cli) provides cross-platform commands for working with Azure, including support for managing deployment slots on Azure Websites.
azure site list
For information about the Azure websites in the current subscription, call azure site list, as in the following example.
azure site list siteslotstest
azure site create
To create a site slot for any website in Standard mode, call azure site create and specify the name of an existing site and the name of the slot to create, as in the following example.
azure site create siteslotstest --slot staging
To enable source control for the new slot, use the --git option, as in the following example.
azure site create --git siteslotstest --slot staging
azure site swap
To make the updated deployment slot the production site, use the azure site swap command to perform a swap operation, as in the following example. The production site will not experience any down time, nor will it undergo a cold start.
azure site swap siteslotstest
azure site delete
To delete a deployment slot that is no longer needed, use the azure site delete command, as in the following example.
azure site delete siteslotstest --slot staging
Azure Web Sites – block web access to non-production deployment slots
Microsoft Azure Free Trial