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.
Deployment Slots Support Details
Four deployment slots in addition to the production slot are supported for each website in the Standard web hosting plan.
Multiple deployment slots are only available for sites in the Standard web hosting plan. When your website has multiple slots, you cannot change the web hosting plan.
Scaling is not available for non-production slots.
Linked resource management is not supported for non-production slots.
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 non-production slot must once again share the same web hosting plan with the production slot before you can swap the two slots.
To Add a Deployment Slot to a Website
The website must be running in the Standard hosting plan to enable multiple deployment slots.
- In the Azure Preview Portal, open your website's blade.
Click Deployment slots. Then, in the Deployment slots blade, click Add 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 a slot blade, 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 add 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 Deployment slots blade, click the deployment slot to open a blade for the slot, with a set of metrics and configuration just like any other website. your-website-name-deployment-slot-name will appear at the top of blade to remind you that you are viewing the deployment slot.
Click the site URL in the slot's blade. 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 Websites – 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.
Configuration for Deployment Slots
When you clone configuration from another deployment slot, the cloned configuration is editable. Furthermore, some settings will follow the content across a swap (not slot specific) while other settings will stay in the same slot after a swap (slot specific). The following lists show the configuration that will change when you swap slots.
Settings that are swapped:
- General settings - such as framework version, 32/64-bit, Web sockets
- App settings (can be configured to stick to a slot)
- Connection strings (can be configured to stick to a slot)
- Handler mappings
- Monitoring and diagnostic settings
Settings that are not swapped:
- Publishing endpoints
- Custom Domain Names
- SSL certificates and bindings
- Scale settings
To Swap Deployment Slots
Before you swap a staging website from a deployment slot into production, make sure that all non-slot specific settings are configured exactly as you want to have it in production.
To swap deployment slots, click the Swap button in the command bar of the website or in the command bar of a deployment slot. Make sure that the swap source and swap target are set properly. Usually, the swap target should be the production slot.
Click OK 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 blade for a deployment slot, click Delete in the command bar.
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 Websites – block web access to non-production deployment slots
Microsoft Azure Free Trial