DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Simplified Solution: Troubleshooting Backend API Failures in Azure Cloud
  • Auto-Instrumentation in Azure Application Insights With AKS
  • How To Use AzureSignTool to Sign Executables With Azure DevOps
  • Empowering Secure Access: Unleashing the Potential of Microsoft Entra ID Application Proxy

Trending

  • Building a Real-Time Audio Transcription System With OpenAI’s Realtime API
  • Using Java Stream Gatherers To Improve Stateful Operations
  • Navigating Change Management: A Guide for Engineers
  • A Guide to Auto-Tagging and Lineage Tracking With OpenMetadata
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Azure Web Apps: Seamless Deployments With Deployment Slots

Azure Web Apps: Seamless Deployments With Deployment Slots

This article will show you how to swap deployment slots to deploy a tested app to production and roll back to a previous version when unexpected issues arise.

By 
Sanjeev Kumar user avatar
Sanjeev Kumar
·
Jan. 21, 25 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
2.9K Views

Join the DZone community and get the full member experience.

Join For Free

Suppose you work for a healthcare company that provides its services via a web platform. The user interface for this platform is set up as a PHP web app hosted in Azure App Services. Frequent updates to the app's source code are rolled out to production to enhance features or address bugs. However, these updates sometimes introduce problems:

  • Undetected bugs: Despite rigorous testing, testers occasionally miss critical bugs, leading to issues in the production environment.
  • Downtime: When bugs are identified, rolling back changes causes service interruptions, which frustrates end-users.
  • Slow deployments: The deployment and compilation process affects app responsiveness, especially during peak usage times, leading to user dissatisfaction.

Is there a better solution to ensure seamless updates without interrupting the services? Yes! Microsoft Azure offers a powerful feature known as deployment slots.

Azure Deployment Slots

Microsoft Azure’s deployment slots provide an efficient and reliable way to manage application updates. With deployment slots, you can maintain both the new and old versions of your application simultaneously. Swapping between the two versions is as simple as a few mouse clicks, eliminating the need for time-consuming code rollbacks. 

What are Deployment Slots, and How Do They Work?

Azure Deployment Slots is a feature in Azure App Services that allows you to create separate environments for deploying and testing your web app before making it available to all end users. Each deployment slot operates as an independent instance of your app, which can be customized for specific purposes, such as: 

  • Staging: To test and validate changes before moving to production.
  • Production: To serve end-users with a stable version of the app.
  • Additional slots: Depending on your pricing plan, you can create slots for QA, testing, or other environments.

Key Features of Deployment Slots

Pre-Warmed Instances

When you deploy to a staging slot, the slot is pre-warmed. This means the app is fully initialized and ready to handle user requests with minimal latency.

Swapping the staging slot into production ensures there is no downtime or cold-start delay.

Seamless Traffic Redirection

During the swap, traffic redirection between slots is seamless, ensuring no user requests are dropped.

Rollback Capability

If unexpected issues arise after swapping a new version into production, you can immediately swap back to the "last known good" configuration.

How Deployment Slots Address the Problem

Bug Detection Before Production

By deploying the new code to a staging slot, testers can validate the app in an environment that mirrors production. This minimizes the risk of undetected bugs. 

No Service Interruptions

Since the app is pre-warmed in the staging slot, swapping to production occurs without downtime, providing uninterrupted services to end-users.

Faster Deployments

Swapping slots is instantaneous compared to traditional deployment methods, significantly reducing the time needed for deployment and improving responsiveness.

Setting Up and Configuring an Azure Web App

1. Create a Web App

Sign in to the Azure portal with your account. Search for App Services and click it.

Search for App Services and click it

Click on Web App.

Click on Web App

Select 1 to 7 values as required for your application, then click on Review + create, followed by Create. The name of the Web App in this demo is webappdemotosrs.

The name of the Web App in this demo is webappdemotosrs

Click on Review + create

Click on Go to resource.

Click on Go to resource

webappdemotosrs (Web App) can be accessed via the Default domain URL.

Accessing via Default domain URL

Accessing via Default domain URL


2. Deployment Slots Creation

Click on the Deployment slots pane.

Click on the Deployment slots pane

Click on Add slot.

Click on Add slot

Give the slot a Name.

Give the slot a Name
Choose whether to clone settings from another slot. If you choose to clone, settings are copied to your new slot from the slot you specify.

Click on Add.

Click on Add
Slot creates with the given name.

Slot creates with the given name

Configure Web App Deployment Settings

In this task, you will configure Web App deployment settings. Deployment settings allow for continuous deployment. This ensures that the app service has the latest version of the application. In the staging slot, select Deployment Center and then select Settings. In the Source drop-down list, select External Git. Notice the other choices.

  • In the repository field, enter: https://github.com/Azure-Samples/php-docs-hello-world.
  •  In the branch field, enter master. Select Save.
  • From the staging slot, select Overview.
  • Select the Default domain link, and open the URL in a new tab.
  • Verify that the staging slot displays Hello World.

Verify that the staging slot displays Hello World

3. Deployment Slots Swap

Click on Swap.

Click on Swap

Click on Start Swap.

Click on Start SwapClick on Start Swap

Once the swapping is completed, a notification will pop up showing its status.

A notification will pop up showing its status


4. After Deployment Slots Swap

Production Default Domain URL output:

Staging Default Domain URL output will be like below

Production Default Domain URL output

This demonstrates that after a deployment slot swap, the production slot begins running the new code while the staging slot reverts to the old code.

Summary

In this article, we learned how to create and use deployment slots in Azure App Service. We used slots to test and stage new versions of our app and swapped those deployment slots. We can swap slots to deploy a tested app to production and roll back a deployed app when unexpected problems arise. When using deployment slots, remember that Azure warms up an app before a swap, and traffic redirection is instantaneous. The result is that your app is deployed without service interruptions or its performance drops.

Azure Web Apps Web apps application azure

Published at DZone with permission of Sanjeev Kumar. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Simplified Solution: Troubleshooting Backend API Failures in Azure Cloud
  • Auto-Instrumentation in Azure Application Insights With AKS
  • How To Use AzureSignTool to Sign Executables With Azure DevOps
  • Empowering Secure Access: Unleashing the Potential of Microsoft Entra ID Application Proxy

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!