Ova

What is the Deployment Slot Setting?

Published in Deployment Slots 4 mins read

A deployment slot setting refers to the configurable environments provided by platforms like Azure App Service, which are essentially live apps with their own host names. These environments allow developers to stage different versions of their application and manage their configurations independently, facilitating robust and reliable deployment processes. Crucially, app content and configuration elements can be swapped between two deployment slots, including the production slot, enabling seamless updates and rollbacks.

Understanding Deployment Slots

Deployment slots are a powerful feature designed to streamline the continuous integration and continuous deployment (CI/CD) pipeline for web applications. Instead of deploying directly to your live production application, you can deploy to a staging slot, test it thoroughly, and then swap it with the production slot. This process significantly reduces downtime and risk associated with new deployments.

Key Benefits of Using Deployment Slots

  • Zero-Downtime Deployments: Swapping slots is a quick operation. The target slot instances are warmed up before the swap, ensuring no cold starts for your users.
  • Easy Rollback: If an issue arises post-swap, you can immediately swap back to the previous, stable version in the original production slot.
  • A/B Testing and Traffic Splitting: You can route a percentage of user traffic to a non-production slot to test new features with a subset of users before a full rollout.
  • Pre-production Validation: Test new application builds in a production-like environment before exposing them to all users.
  • Reduced Risk: New deployments don't directly affect the live production site until they are thoroughly validated.

Core Deployment Slot Settings and Configurations

While the content of your app (code, files) is what primarily changes between deployments, deployment slots also manage various configuration settings. It's critical to understand which settings are slot-specific (sticky) and which swap with the application content.

Settings That Swap (General Settings)

When you swap two slots, the following elements generally move with the swapped application content:

  • App settings (unless marked as slot-specific)
  • Connection strings (unless marked as slot-specific)
  • Handler mappings
  • Web.config modifications (related to content)
  • Application settings like framework versions, 32/64-bit status, Web Sockets.

Essentially, anything that defines the behavior of the application itself, as distinct from the hosting environment, typically swaps with the code.

Sticky Settings (Slot-Specific Settings)

These are configurations that remain with the slot even after a swap. They are tied to the specific environment of that slot, not the application content. This is crucial for maintaining environmental consistency (e.g., a staging database connection string should always point to the staging database, regardless of which app version is in the slot).

To make an app setting or connection string sticky to a slot, you typically mark it as a "deployment slot setting" in the platform's configuration interface (e.g., in Azure App Service settings, there's a checkbox for this).

Common sticky settings include:

  • Endpoint URLs for external services (e.g., API gateways, external authentication providers specific to the environment).
  • Monitoring and Diagnostic settings: Log levels, application insights instrumentation keys.
  • Authentication/Authorization settings: Client IDs/secrets that are environment-specific.
  • Scaling configurations: While less common to be strictly "sticky" in the same way as app settings, scaling rules are usually configured per slot if you want different performance characteristics for staging vs. production.
  • Virtual Network integration settings: Determines network isolation for the slot.

Practical Example: Using Sticky Settings

Imagine you have a Production slot and a Staging slot.

Setting Name Production Slot Value Staging Slot Value Sticky?
DATABASE_CONNECTION prod-db-connection-string staging-db-connection-string Yes
API_BASE_URL https://api.myapp.com https://staging-api.myapp.com Yes
APP_VERSION v1.0 (after swap) v2.0 (after swap) No
FEATURE_TOGGLE_NEW_UI false true No

When you deploy v2.0 to the Staging slot, it will have FEATURE_TOGGLE_NEW_UI=true and use staging-db-connection-string.
When you swap Staging (containing v2.0) with Production (containing v1.0):

  1. The v2.0 code and its non-sticky settings (APP_VERSION, FEATURE_TOGGLE_NEW_UI) move to the Production slot.
  2. The v1.0 code and its non-sticky settings move to the Staging slot.
  3. The sticky settings (DATABASE_CONNECTION, API_BASE_URL) remain with their respective slots. So, v2.0 (now in Production) will correctly connect to prod-db-connection-string, and v1.0 (now in Staging) will connect to staging-db-connection-string.

This mechanism ensures that your application always connects to the correct environmental resources, regardless of which version is currently active in a specific slot. For more details on configuring deployment slots, refer to official documentation, such as the Azure App Service Deployment Slots guide.