Welcome!

Blog Feed Post

Why Azure deployment slots are awesome and how to use them

Azure App Services is 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 that you can leverage, 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 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:

azure-slots-diagram

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 you original Web App. 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.

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 now Swap 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 more, things that make deployment slots awesome, let me state out 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 it’s 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 at how to setup deployment slots and what the major benefits are in more detail.

Setting up 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 Azure deployment slots

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 connectionstrings in these settings.

Visit my Pluralsight course for a full video tutorial about setting up and using deployment slots.

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:

Deploy to azure deployment slot

 

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

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 amid doing something that depends on 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 rollback 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:

Deployment slot settings

Swap with preview

You can choose to swap with 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 perform the swap
Swapping an Azure Deployment Slot with preview

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:

azure slot 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:

slot percentage traffic

With testing in production, you can have some users use 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 setup. In the Azure Portal, choose the testing in production menu option in your App Service.

Door computer gegenereerde alternatieve tekst: Search (Ctrl +1) App Service Editor (P reviev•) Performance test Resource explorer pep Debugging Testing in production Extensions Save X Disca rd Static Routing O Choose deployment slot Add Slot TRAFFIC Traffic %

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

Start using deployment slots and use them wisely! Let me know what you think in the comments!

The post Why Azure deployment slots are awesome and how to use them appeared first on Stackify.

Read the original blog entry...

More Stories By Stackify Blog

Stackify offers the only developers-friendly solution that fully integrates error and log management with application performance monitoring and management. Allowing you to easily isolate issues, identify what needs to be fixed quicker and focus your efforts – Support less, Code more. Stackify provides software developers, operations and support managers with an innovative cloud based solution that gives them DevOps insight and allows them to monitor, detect and resolve application issues before they affect the business to ensure a better end user experience. Start your free trial now stackify.com

Latest Stories
Modern software design has fundamentally changed how we manage applications, causing many to turn to containers as the new virtual machine for resource management. As container adoption grows beyond stateless applications to stateful workloads, the need for persistent storage is foundational - something customers routinely cite as a top pain point. In his session at @DevOpsSummit at 21st Cloud Expo, Bill Borsari, Head of Systems Engineering at Datera, explored how organizations can reap the bene...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
Kubernetes is an open source system for automating deployment, scaling, and management of containerized applications. Kubernetes was originally built by Google, leveraging years of experience with managing container workloads, and is now a Cloud Native Compute Foundation (CNCF) project. Kubernetes has been widely adopted by the community, supported on all major public and private cloud providers, and is gaining rapid adoption in enterprises. However, Kubernetes may seem intimidating and complex ...
In his session at 21st Cloud Expo, Michael Burley, a Senior Business Development Executive in IT Services at NetApp, described how NetApp designed a three-year program of work to migrate 25PB of a major telco's enterprise data to a new STaaS platform, and then secured a long-term contract to manage and operate the platform. This significant program blended the best of NetApp’s solutions and services capabilities to enable this telco’s successful adoption of private cloud storage and launching ...
In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
In his general session at 21st Cloud Expo, Greg Dumas, Calligo’s Vice President and G.M. of US operations, discussed the new Global Data Protection Regulation and how Calligo can help business stay compliant in digitally globalized world. Greg Dumas is Calligo's Vice President and G.M. of US operations. Calligo is an established service provider that provides an innovative platform for trusted cloud solutions. Calligo’s customers are typically most concerned about GDPR compliance, application p...
Digital transformation is about embracing digital technologies into a company's culture to better connect with its customers, automate processes, create better tools, enter new markets, etc. Such a transformation requires continuous orchestration across teams and an environment based on open collaboration and daily experiments. In his session at 21st Cloud Expo, Alex Casalboni, Technical (Cloud) Evangelist at Cloud Academy, explored and discussed the most urgent unsolved challenges to achieve f...
You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, discussed how given the magnitude of today's application ...
The dynamic nature of the cloud means that change is a constant when it comes to modern cloud-based infrastructure. Delivering modern applications to end users, therefore, is a constantly shifting challenge. Delivery automation helps IT Ops teams ensure that apps are providing an optimal end user experience over hybrid-cloud and multi-cloud environments, no matter what the current state of the infrastructure is. To employ a delivery automation strategy that reflects your business rules, making r...
As you move to the cloud, your network should be efficient, secure, and easy to manage. An enterprise adopting a hybrid or public cloud needs systems and tools that provide: Agility: ability to deliver applications and services faster, even in complex hybrid environments Easier manageability: enable reliable connectivity with complete oversight as the data center network evolves Greater efficiency: eliminate wasted effort while reducing errors and optimize asset utilization Security: imple...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
Blockchain is a shared, secure record of exchange that establishes trust, accountability and transparency across business networks. Supported by the Linux Foundation's open source, open-standards based Hyperledger Project, Blockchain has the potential to improve regulatory compliance, reduce cost as well as advance trade. Are you curious about how Blockchain is built for business? In her session at 21st Cloud Expo, René Bostic, Technical VP of the IBM Cloud Unit in North America, discussed the b...