Microsoft Azure App Service Slots

In this article, I will talk about the Azure App Service and App Service Staging Slots logic, which is one of the most used services on Azure and which is used by everyone who develops, manages, hosts, or hosts an application.

What is App Service ?


In its simplest definition, Azure App Service is an HTTP based hosting service. App Service provides us with a hosting service to host the Web, API, Mobile Backend or any of our applications. By providing this service in the Azure Platform As a Service logic, it enables us to manage the environment we will use from the Azure Portal. We don’t have to deal with virtual machines running in the background, security risks or making updates. Your applications will stand up in minutes like all other Azure services and start working on live systems. Besides the hosting service offered by this service, it has very powerful features such as auto-scale, defining authentication methods without writing code, auto-deployment, hybrid connections.  Deployment Slots, which I will talk about in this article, is one of these features.


What is Deployment Slots and How to Use It?

If you ask me, it is useful for users who benefit from Deployment Slots feature to all App Service service. To explain this with an example;

Let’s say we have a website and its URL is datamarket.com.tr. There is a development on this website and new versions are constantly being published. These changes are a test phase and tests are carried out by test users to detect errors such as incompatibilities and bugs. This test environment usually brings a separate workload as management and requires effort as much as production. Deployment Slot comes into our lives exactly at this point. I can easily add a new slot next to my Production Slot in App Service. This slot works like a unique instance and has its own unique features. It creates its own URL, such as datamarket-beta.com.tr in the name of your choice, and allows you to upload your new version to this test slot first. This slot is created as a copy of the production slot if you want, creates an empty instance and also provides you with its own FTP address. After testing your application in this test slot, you can easily swap it.

Creating Deployment Slots

To create a Deployment Slot, we first need an App Service. There is a Deployment Slots feature under the Deployment Tab in App Service.

From this tab we can manage our Staging Slots. When we enter the tab, we encounter a default stage as Production stage. This is the slot that our app is currently running.

We are adding a new Stage by clicking Add Slot.

Here, with clone settings feature, we can create a new instance with the same features or we can create empty instance.

Our new Slot has been created and the traffic option on the right side catches our eye. Traffic feature is very easy to use and it is a very efficient feature in the background, because when we set the traffic percentages as in the image above, 85% of the users who access the application are directed to the production slot, while 15% can be directed to the test slot and we do not deal with its configuration. Azure automatically routes this on the back.

Swap Operation

We have two Urls and environment. These are datamarket.com.tr and datamarket-beta.com.tr. After doing the deployment in my test environment, I want to switch this environment to production. To do this, I need to swap from the Deployment Slots tab. This process does the following steps for us in the background :

  •  Applies all configurations in Production Slot to target slot (Continuous deployment, Authentication, Connection Strings).
  •  The configurations in the first step are applied sequentially, and if one of them fails, the swap is stopped and the changes are undone.
  • Virtual IP addresses are changed, so Urls are changed as well.

When we do this, our beta slot will appear as Production and our test slot will have the production URL.

Perform Swap with Preview

If you use this option, App Service will pretend like actually swap and validate it. The advantage of this process is that all the settings can be applied without any problems first and foremost. If there is no problem, Swap can be done without error.

Auto Swap

The Auto Swap feature is a feature that can be opened from the slot instance and automatically changes to the production slot whenever the new version is deployed into the slot. You can find this feature in General Settings tab from the configuration tab on our slot instance page.

Azure DevOps and App Service Slots

Let’s say we have a system and application as above. Our environment is constantly being developed and a new version is released. This new version is first deployed in the test slot and then approved in the production environment. There is a service that we can build this scenario from end to end; Azure DevOps Service.

With Azure DevOps Service, we can configure our CI / CD processes and provide deployment to the production environment after testing, primarily as desired. Let’s create this process step by step with the pipelines feature of Azure DevOps:

We create a new pipeline as in the image above. Our Pipeline will consist of two steps. The first is test deployment and the second is Prod Deployment and we will build an approval mechanism between these processes.

In beta deployment stage, we apply our settings for a deployment to the slot of our App Service as follows.

After making our related settings, we apply the approval mechanism as follows.

In the second step, if we want, we can trigger the slot swap feature or we can also get a deployment in the production environment after approval.

When we run Pipeline, an approval mechanism works as follows:

References :

https://docs.microsoft.com/en-us/azure/app-service/overview

https://docs.microsoft.com/en-us/azure/app-service/deploy-staging-slots

Previous Post

Desktop Virtualization on Azure

Next Post

How to Use Microsoft Teams – Digital Office with Teams

Leave a Reply

FOR NEW EXPERIENCE

Contact with us

Stop worrying about technology issues. Just focus on your work. Let us identify and manage the technology you need for you.
Start typing to see you are looking for.
Cookie Notice
We use cookies to analyze usage on our site, to personalize content and ads, to measure the effectiveness of advertising campaigns and to remember your visit preferences.
Accept