Back to Insights
Cloud Computing

Zero-Downtime Deployments on Azure: A Practical Guide

C

CodeCrafts DevOps

Engineering Team

Zero-Downtime Deployments on Azure: A Practical Guide

Can you deploy a new version of a web application on Azure without users noticing? Yes. With Azure App Service deployment slots, a CI/CD pipeline and a few disciplined engineering habits, most releases can go live with no planned downtime and a quick path back if something goes wrong. The platform features do much of the heavy lifting, but true zero-downtime also depends on how you handle warm-up, configuration, sessions and, above all, database changes.

Why downtime during deployment still matters

The cost of an outage is different for every organisation, but the pattern is familiar. A hospital cannot pause patient registration, a college portal cannot go offline on results day, and an online store loses orders and trust every time a checkout fails. Traditional deployments, where servers were stopped, files copied and services restarted, created exactly these gaps. They also encouraged teams to release less often and in bigger batches, which made each release riskier.

Zero-downtime deployment changes that equation. When releasing is routine and reversible, teams ship smaller changes more frequently, and problems are easier to isolate.

How Azure deployment slots work

A deployment slot is a separate, live instance of your App Service app with its own hostname, running on the same App Service plan as production. Slots are available on the Standard, Premium and Isolated tiers; the number of slots allowed depends on the tier.

The core idea is simple: deploy the new version to a staging slot, verify it, then swap the staging and production slots. During a swap, Azure:

  1. Applies the production slot's sticky settings (such as connection strings marked as "deployment slot settings") to the staging instances.
  2. Restarts those instances with the new configuration and waits for them to warm up.
  3. Switches routing so production traffic goes to the warmed-up instances, and the previous version moves into the staging slot.

Because the old version is still running in the staging slot after the swap, rolling back is just another swap. That is one of the most valuable properties of this approach.

A practical CI/CD pipeline

A typical pipeline using GitHub Actions (Azure DevOps Pipelines works the same way) looks like this:

  1. Merge to the main branch after code review and passing pull-request checks.
  2. Build and test. The workflow compiles the application, runs unit and integration tests, and produces a versioned build artefact.
  3. Authenticate securely. Use OpenID Connect federated credentials with the azure/login action rather than storing long-lived secrets in the repository.
  4. Deploy to the staging slot using the azure/webapps-deploy action or the Azure CLI.
  5. Warm up and verify. Hit health-check endpoints and run a short suite of smoke tests against the staging slot's URL.
  6. Swap. Trigger the swap, optionally after a manual approval step for production.
  7. Monitor. Watch error rates and response times in Application Insights for a defined period, and swap back if they degrade.

Getting warm-up and configuration right

Most problems with slot swaps come from a handful of details:

  • Warm-up. Configure application initialisation (for example, the applicationInitialization section in web.config, or the WEBSITE_SWAP_WARMUP_PING_PATH app setting) so Azure calls a meaningful endpoint before routing traffic. A warm-up that only returns a static page will not catch a broken database connection.
  • Sticky settings. Decide which settings belong to the environment (production database, payment gateway keys) and mark them as slot settings, so they stay with the slot rather than moving with the code.
  • Swap with preview. For extra safety, use a multi-phase swap: Azure applies production settings to the staging slot and pauses, so you can test it with production configuration before completing the swap.
  • Health checks. Enable the App Service Health check feature so unhealthy instances are removed from the load balancer automatically.
  • Avoid in-memory state. In-process sessions and caches are lost on swap. Keep sessions in a distributed store such as Azure Cache for Redis or use token-based authentication.

It is also worth being realistic. Azure is designed so that in-flight requests complete during a swap, but long-running requests and persistent connections such as WebSockets can be interrupted. Clients should be built to reconnect gracefully.

The hard part: database changes

Slots swap application code, not your database. Both the old and new versions of the application will talk to the same database for at least a short period, and the old version must keep working if you roll back. The proven technique is the expand and contract pattern:

  1. Expand: add new tables or nullable columns in a backward-compatible migration, deployed before or with the new code.
  2. Migrate: release code that writes to both old and new structures, and backfill existing data.
  3. Contract: once the old code is no longer in use, remove obsolete columns in a later release.

Renaming or dropping a column in a single release is the most common way "zero-downtime" deployments end up causing outages. Feature flags help too, allowing new behaviour to be deployed dark and switched on independently of the release.

Beyond deployment slots

Once slot swaps are routine, teams can consider routing a small percentage of production traffic to the staging slot for testing in production, or blue-green and canary releases on Azure Kubernetes Service or Azure Container Apps for more complex architectures. For most business applications, however, well-configured deployment slots provide an excellent balance of safety and simplicity.

Key takeaways

  • Azure App Service deployment slots let you deploy, verify and swap releases with no planned downtime.
  • The previous version stays in the staging slot, so rollback is a quick swap back.
  • Meaningful warm-up endpoints, sticky settings and health checks are essential.
  • Keep applications stateless and design clients to reconnect after brief interruptions.
  • Use the expand and contract pattern so database changes remain backward compatible.

How CodeCrafts handles releases

At CodeCrafts, automated build, test and staged deployment are part of every project from the start, not an afterthought. Systems such as our hospital management software are used around the clock, so we plan backward-compatible database migrations, monitor each release and keep a rollback path ready. Whether you run on Azure or another cloud, we can help you set up a release process your users never notice. To review your current deployment pipeline, talk to our team.

Need expert engineering for your next project?

Talk to our team
Chat on WhatsApp
Let's build something epic!