Azure App Services are extremely useful for developers. It offers Web Apps, API Apps, Mobile Apps and Function Apps (that run Azure Functions). These apps are incredibly powerful and can literally get you up and running in minutes. They provide a host of amazing features like (auto)scaling, easy authentication, offline sync (for Mobile Apps), hybrid connections and much, much more. One feature that these apps share is probably the most underrated one that many people don’t know about: deployment slots.
What Are Azure App Service Deployment Slots?
Deployment slots are incredible! They are the reason for many people to start using Azure App Services, like Web Apps. Let me explain why.
Suppose that you have a Web App deployed in an Azure App Service and it has a URL like production.website.com. In Azure App Services, you can very easily add an additional deployment slot. This is a full-fledged App Service – in this case, another Web App – that sits next to your original Web App. The deployment slot has a different URL, maybe something like staging.website.com. Your users would be accessing your original Web Appbecause that is your production environment slot. You can deploy a new version of the Web App into a secondary deployment slot, so you can test it before it goes live.
Instead of deploying your Web App to a staging slot, you could have deployed it as whole new App Service. But here is the magic of deployment slots: you can nowswap the staging deployment slot with production within your same App Service. When you do this, users will notice almost nothing and experience no downtime. The swap functionality of the deployment slot takes care of this magic. Isn’t that awesome?
Deployment Slot Facts
Before I tell you even moreabout what make Azure deployment slots awesome, let me state the facts about deployment slots:
- Each deployment slot is like a full-fledged App Service instance.
- The original App Service deployment slot is also called the production slot.
- Deployment slots can copy the configuration (AppSettings and Connectionstrings) of the original App Service or other deployment slots.
- When you scale a deployment slot (up or out), you also scale all the other slots of the App Service. This is because all slots share the same App Service Plan.
- Because all deployments lots run within the same App Service and its App Service Plan, deployment slots are free to use if you are using the Standard pricing tier or higher.
- If you have installed any site extensions, you need to do that again in a deployment slot, as it is a new App Service instance.
- Deployment slots have a different URL than the original App Service. This URL is based on the name you give the deployment slot. For instance, “staging” can become http://website-staging.azurewebsites.net.
Alright, let’s look in more detail at how to set up Azure deployment slots and what the major benefits are.
Setting Up Azure App Service Deployment Slots
Creating a deployment slot is very easy and, as always, there are many ways to do it. You can use the Azure Portal, Azure CLI, Azure PowerShell and the Azure Management API. I’ll show you how to do it using the Azure Portal.
In the Azure Portal, navigate to your App Service – let’s say it’s a Web App – and click the deployment slots menu item:
Creating an Azure deployment slot
Now you see the Add Slot button, which opens the Add Slot dialog, to the right of the screen. Here, you need to enter a name, and choose if you want to copy the configuration from another slot, or not at all. Click OK and voila, you have a deployment slot!
Choosing to copy the configuration is important because your app probably does things like connect to a database or cache and has specific connection strings in these settings.
Want to dig more into Azure? Click below!
Deploying Your App to Deployment Slots
When you have created a deployment slot, it is empty, just like when you create a new App Service. You need to deploy a version of your app to the deployment slot before you can use it.
You can use the same tools and techniques that you use to deploy your app to the App Service: through Visual Studio, using something like VSTS (Visual Studio Team Services) or Octopus Deploy, using Web Deploy or any number of other technologies. Selecting a deployment slot to deploy to from Visual Studio looks like this:
Swap and Rollback
One of the major benefits of deployment slots is that you can swap them. What does that mean?
Swapping
Suppose that I have a website deployed in a Web App. This Web App has the custom URL https://www.azure-overview.com/. I have created a new version of the website and want to test it before publishing it. So, I create a deployment slot called staging, which has the URL http://azureoverview-staging.azurewebsites.net. I’ve made sure that the slot has the same configuration values so that I use the same database and cache as production does. I’ve deployed the new website in the deployment slot and I’m happy with my changes and want to deploy to production. I can do this by performing a swap:
Swapping an Azure Deployment Slot
I can do this from the Azure Portal, Azure CLI, Azure PowerShell and the Azure Management API. In the Azure Portal, I can choose what the source and destination slots are and click OK. This will swap the slots and will deploy my changes to production. Here’s the thing: users will experience no downtime!
And that’s because a swap does the following:
- The source slot will be warmed-up. Azure does this by firing a couple requests into the root of the slot. You can also configure custom warm-up rules.
- Azure swaps the Virtual IP addresses of the source and destination slots, thereby swapping the URLs of the slots.
- It also applies (or keeps, depending on how you see it) certain settings that are specific to the target slot.
- Publishing endpoints
- Custom Domain Names
- SSL certificates and bindings
- Scale settings
- WebJobs schedulers
- Site extensions
This results in a seamless transition to production. Users experience virtually no downtime. I say “virtually” because users that are doing something that depends on the state that is in memory of the Web App will lose this state. But you shouldn’t keep state locally in an App Service anyways in Azure. as you should assume that everything in Azure is volatile.
Rollback
After a swap, the “old” website will be in the staging slot and the “new” website in the production slot.
If you aren’t happy with the version in production, you can easily roll back your deployment. Simply swap back to reverse the effect!
Swapping Options
You can swap deployment slots manually, but you have more options that you should consider.
Auto Swap
You can choose to swap automatically to a slot when there is a new version of your app in a deployment slot – this is called Auto Swap. Simply enable it in the Application Settings of the deployment slot:
Swap with Preview
You can choose to swap with a preview when you perform a swap from the Azure Portal. This does the following:
- It performs the swap in stages.
- It applies the configuration elements of the destination slot to the source slot,so you can test if everything works as expected, before the actual swap happens.
- If you complete the swap, it does the same as in a manual swap, warm-up the slot and performs the swap.
Swapping an Azure Deployment Slot with preview
Swap and VSTS
If you use something like VSTS (Visual Studio Team Services), you can also leverage deployment slots and the swap feature. You can deploy a new version of your app to a deployment slot and then swap it using steps in a release definition. The illustration below shows this for a release definition in VSTS:
Testing in Production
Besides swapping, deployment slots offer another killer feature: testing in production. Just like the name suggests, using this, you can actually test in production. This means that you can route a specific percentage of user traffic to one or more of your deployment slots:
With testing in production, you can have some users test the new version of your application. This way, you can see if and how they use new features. In order to find this out, you need to make sure that you monitor everything, with something like Stackify Retrace for Azure monitoring.
Setup
Testing in production is easy to set up. In the Azure Portal, choose the testing in production menu option in your App Service.
Here, you can choose the deployment slots that you want to route traffic to (or add new ones) and assign a percentage of traffic to them. That’s it! Now users will be routed to your deployment slots – super powerful!
Conclusion
Deployment slots are awesome and I hope that you give them a chance. You can use them for all sorts of things, but there are also things to keep in mind. Here is the quick overview:
Pros:
- Using the swap feature gives you zero-downtime deployments.
- You can test the new version of your app using the testing in production feature.
- Deployment slots are great to verify a new version of an app before it goes live.
- Deployment slots are free!
Cons:
- A deployment slot is a new App Service. This means that you must reinstall any site extensions that you have installed in your App Service.
- Your App Service needs to (at least) be in the Standard Pricing tier.
- You can’t scale a deployment slot, separate from other deployment slots in the App Service. This makes a deployment slot not suitable for performance testing – you should use a separate App Service for that. Read more about the types, steps and best practices to consider when performance testing here.
Start using deployment slots and use them wisely! Let me know what you think in the comments!
- About the Author
- Latest Posts
About Barry Luijbregts
Barry is a software architect and developer and Pluralsight author with a passion for the cloud. He has worked for lots of companies throughout the last decade and is keen to share his knowledge with the community. He co-runs a usergroup focused on technology and soft-skills called .NET Zuid and currently teaches people about the benefits of the cloud. @AzureBarry AzureBarry.com
- Testing in Production with Microsoft Azure - March 1, 2018
- How to DevOps with Azure - February 28, 2018
- Compare Azure SQL Database vs. Azure SQL Data Warehouse: Definitions, Differences and When to Use - February 14, 2018
- .NET Standard Explained: How To Share Code - January 23, 2018
- How to Build Cross-Platform .NET Core Apps - January 15, 2018
FAQs
What is the use of deployment slots in Azure? ›
Azure Functions deployment slots allow your function app to run different instances called "slots". Slots are different environments exposed via a publicly available endpoint. One app instance is always mapped to the production slot, and you can swap instances assigned to a slot on demand.
Which of the following is an advantage of using deployment slots? ›Deploying your application to a deployment slot has the following benefits: You can validate web app changes in a deployment slot before swapping it with the another slot. Eliminate downtime on deployment, and automate the swapping. Easy to swap a bad deployment back.
How many maximum deployment slots can be there in one app service plan? ›Deployment slots are only supported in the Standard, Premium, and Isolated tiers. The Standard tier supports up to 5 slots, but the Premium and Isolated tiers support up to 20.
How many deployment slots we can get with standard tier of the app service plan? ›To scale your app to a different tier, make sure that the target tier supports the number of slots your app already uses. For example, if your app has more than five slots, you can't scale it down to the Standard tier, because the Standard tier supports only five deployment slots.
What are the 3 deployment modes that can be used for Azure? ›Azure supports three approaches to deploying cloud resources - public, private, and the hybrid cloud. Selecting between them will change several factors of the services you move into Azure including cost, maintenance requirements, and security.
What are Web app deployment slots and how can they be used? ›The deployment slot has a different URL, maybe something like staging.website.com. Your users would be accessing your original Web App because that is your production environment slot. You can deploy a new version of the Web App into a secondary deployment slot, so you can test it before it goes live.
What are the benefits of application deployment? ›- Saving Time. Application deployment can occur rapidly within hours and installation quickens, too.
- Stronger Security. ...
- Enhanced Visibility. ...
- Simpler Software Updates.
Azure Web Sites has increased the number of deployment slots for Standard websites to 4 (in addition to the Production slot). This gives you more deployment options, since you can keep multiple versions of your site and alternate between them while continuing to develop. Learn more.
What is the benefit of deploying? ›The value of deployment automation for any business is exponential, but these are some critical benefits that deployment automation can bring to your business or organization: Anyone can deploy. Faster, more efficient deployment. Increased productivity.
How many additional deployment slots can you create in Azure? ›Deployment slots are a feature of Azure App Service Plans. As a result, every App Service resource (Web App, Web API, Mobile App) in Microsoft Azure has the ability to create up to 4 additional deployment slots with the Standard tiers, and up to 20 deployment slots with the Premium tiers.
Can we deploy multiple applications on same server? ›
To run multiple applications on the same server
Add an app to the stack for each application. Obtain a separate subdomain for each app and map the subdomains to the application server's or load balancer's IP address. Edit each app's configuration to specify the appropriate subdomain.
No, there is no single command you can use to deploy the same application to different Orgs. The only workaround you can use is - create shell script to target different Org once you are done with push to one Org.
How many resource groups can I deploy to in a single deployment operation? ›Deploy to multiple resource groups
The resource groups can exist in different subscriptions. You can deploy to 800 resource groups in a single deployment.
You can host up to 100 apps in a single app service plan, but the key thing to know here is that as with the free plan you are charged per app, not per app service plan. Each instance of a web app you deploy in the shared plan get's it's own 240 CPU minutes limit and is charged per app.
How many minimum instances of a role should be deployed to guarantee Azure SLA? ›What is Azure Service Level Agreement (SLA)? The Azure Compute SLA guarantees that, when you deploy two or more role instances for every role, access to your cloud service will be maintained at least 99.95 percent of the time.
What are the 4 types of deployment cloud services? ›NIST defines four cloud deployment models: public clouds, private clouds, community clouds, and hybrid clouds. A cloud deployment model is defined according to where the infrastructure for the deployment resides and who has control over that infrastructure.
What are the 3 types of data that can be stored in Azure? ›Microsoft Azure and most other cloud providers offer several different types of storage, each with its own unique pricing structure and preferred use. Azure storage types include objects, managed files and managed disks.
What are the different types of deployment models in Azure? ›There are three different ways to deploy cloud services: on a public cloud, private cloud or hybrid cloud.
What are the different methods of deploying apps? ›You can consider multiple deployment strategies and variations for rolling out new versions of software in a continuous delivery process. This section discusses the most common deployment methods: all at once (deploy in place), rolling, immutable, and blue/green.
What methods can be used to deploy apps to Azure App Service? ›- Deployment Source. A deployment source is the location of your application code. ...
- Build Pipeline. ...
- Deployment Mechanism. ...
- Continuously deploy code. ...
- Continuously deploy containers. ...
- Use Azure DevOps. ...
- Use GitHub Actions. ...
- Use other automation providers.
How do I deploy a web application to Azure App Service? ›
To deploy to any Azure App service (Web app for Windows, Linux, container, Function app or web jobs), use the Azure App Service Deploy task. This task is automatically added to the release pipeline when you select one of the prebuilt deployment templates for Azure App Service deployment.
What are the 3 main steps in the deployment process? ›- Preparation. ...
- Testing. ...
- Deployment.
Systematic communication is an important part of deployment management. Check point meetings need to include decision makers, so that decisions can be made at the spot. With these steps you will avoid many common issues in deployments.
What is the purpose of a deployment plan? ›The purpose of the Deployment Plan is to ensure that the system successfully reaches its users. The Deployment Plan provides a detailed schedule of events, persons responsible, and event dependencies required to ensure successful cutover to the new system.
What are the three types of cloud deployment? ›- Infrastructure as a Service (IaaS) ...
- Platform as a Service (PaaS) ...
- Software as a Service (SaaS)
By far, the most popular cloud deployment model is the public cloud. These services are run by the largest, most reputable cloud providers such as Google, Microsoft, Amazon, and IBM. When using a public cloud service, the provider remains responsible for managing the cloud infrastructure.
Which is the cloud deployment used the most? ›Public Cloud Deployments
The public model is the most widely utilized cloud service because it can be used by everyone. The service provider owns and operates the hardware, and every user availing the service provider shares the same server.
The most common strategy is to use a blue-green deployment. The new version (the blue version) is brought up for testing and evaluation, while the users still use the stable version (the green version). When ready, the users are switched to the blue version.
How do you know if deployment is successful? ›You can check if a Deployment has completed by using kubectl rollout status . If the rollout completed successfully, kubectl rollout status returns a zero exit code. and the exit status from kubectl rollout is 0 (success):
What are the steps in deploying? ›The deployment process flow consists of 5 steps: Planning, development, testing, deploying, and monitoring.
What is the use of deployment groups in Azure DevOps? ›
A deployment group is a logical set of deployment target machines that have agents installed on each one. Deployment groups represent the physical environments; for example, "Dev", "Test", or "Production" environment. In effect, a deployment group is just another grouping of agents, much like an agent pool.
What is an app service deployment slot? ›Azure deployment slots allow your web apps to function in different instances called slots. Slots are different environments accessed through a publically available endpoint. One app instance is always assigned to the production slot, where you can toggle between multiple app instances on demand.
What is deployment in Azure? ›A deployment source is the location of your application code. For production apps, the deployment source is usually a repository hosted by version control software such as GitHub, BitBucket, or Azure Repos. For development and test scenarios, the deployment source may be a project on your local machine.
What are the two common types of deployment strategies used in DevOps? ›- Blue/Green Deployment. In this type of deployment strategy, the new version of the software runs alongside the old version. ...
- Canary Deployment. ...
- Recreate Deployment. ...
- Ramped Deployment. ...
- Shadow Deployment. ...
- A/B Testing Deployment.
- External package URL. You can use an external package URL to reference a remote package (. ...
- Docker container. ...
- Web Deploy (MSDeploy) ...
- Source control. ...
- Local Git. ...
- Cloud sync. ...
- FTP. ...
- Portal editing.
In effect, a deployment group is just another grouping of agents, much like an agent pool. The main difference of Deployment groups and Agent Pools is where they can be used in the azure pipeline. Deployment groups can only be used in the Deployment group job in Classic release pipelines.
What are three activities involved in deploying an application? ›Some of the most common activities of software deployment include software release, installation, testing, deployment, and performance monitoring.
How is deployment done in Azure? ›- Step 1 − Go to your website in Visual Studio.
- Step 2 − Right-click on the name of the application in the solution explorer. ...
- Step 3 − Create a new profile by selecting 'New Profile' from the dropdown. ...
- Step 4 − On the next screen, choose 'Web Deploy Package' in Publish Method.
- Log in to the Azure portal.
- Click Create a resource > Compute, and then scroll down to and click Cloud Service.
- In the new Cloud Service pane, enter a value for the DNS name.
- Create a new Resource Group or select an existing one.
- Select a Location.
- Click Package.
To add a new deployment slot, click Add Slot button at the top. Provide name for the deployment slot. If the name is staging , azure generates the following URL. You can clone your application configuration settings from another already existing deployment slot if you want to.
How many additional deployment slots can you create in addition to the production develop deployment slot? ›
In addition to the Production deployment slot, how many additional deployment slots can you create? You can add additional deployment slots for a total of 5 deployment slots that can be swapped with the production slot, or other non-production slots. The 4 additional slots can be used for staging and testing purposes.
How many instances of a role should be deployed to satisfy Azure SLA? ›The Azure Compute SLA guarantees that, when you deploy two or more role instances for every role, access to your cloud service will be maintained at least 99.95 percent of the time.