Web App Service field-manual-complete field-manual-complete field-manual-complete

Swap with preview

Swap with preview is a safer way to promote an App Service deployment slot. Instead of immediately swapping staging into production, Azure first applies the target slot's relevant configuration to the source slot and lets you verify the app. You can test startup, settings, authentication behavior, warm-up paths, and dependency access before completing the swap. If something looks wrong, you reset the preview and leave production traffic where it was. It is a controlled pause between deployment and commitment.

Aliases
App Service swap with preview, deployment slot swap preview, slot swap preview, preview swap
Difficulty
intermediate
CLI mappings
5
Last verified
2026-05-27T00:59:56Z

Microsoft Learn

Swap with preview is an Azure App Service deployment-slot swap mode that applies target-slot configuration to the source slot, pauses for validation, and then either completes or resets the swap. It reduces surprises before production traffic moves. during controlled releases.

Microsoft Learn: Set up staging environments in Azure App Service2026-05-27T00:59:56Z

Technical context

Technically, swap with preview belongs to Azure App Service deployment slots. It operates at the app platform control plane, not inside your code. During preview, App Service prepares the source slot with target-slot settings so the application can initialize under production-like configuration before the routing change completes. Operators use portal, CLI, PowerShell, or pipelines to start preview, complete swap, or reset. Slot-specific settings, app settings, connection strings, authentication, warm-up behavior, custom domains, and deployment pipelines all affect whether the preview is safe.

Why it matters

Swap with preview matters because slot swaps can fail for reasons that normal staging tests miss. A build may run perfectly with staging settings but break after production connection strings, identity, authentication, or feature flags apply. Preview gives engineers a checkpoint before customer traffic moves. It is especially useful when a web app has slow startup, strict health checks, sticky settings, private dependencies, or compliance-sensitive configuration. Without preview, teams discover bad slot settings during the actual swap and may face a confusing partial state. Used well, swap with preview reduces release anxiety and gives operators a clear decision point: complete, fix, or reset.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

In the App Service Deployment slots blade, swap with preview appears as an option when choosing how to swap staging and production slots during release.

Signal 02

In Azure CLI release logs, the slot swap command uses an action such as preview, swap, or reset for the selected app and target slot.

Signal 03

In application logs during preview, the staging slot may show production-like settings, startup behavior, dependency calls, and health-check results before traffic moves during validation and review.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Validate production app settings and connection strings against a staging build before moving customer traffic.
  • Warm up a slot with production-like configuration when startup time or dependency initialization is risky.
  • Pause a deployment pipeline for smoke tests before completing the final App Service slot swap.
  • Reset a planned swap when preview exposes missing Key Vault permissions, bad feature flags, or failed health checks.
  • Coordinate regulated releases where change approvers need evidence before traffic is routed to a new version.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Tax SaaS avoids release-night configuration failure

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A tax-preparation SaaS company had a narrow release window before a filing deadline. A previous App Service slot swap had exposed a bad production payment-gateway setting only after traffic moved.

Business/Technical Objectives
  • Validate production-like settings before routing customers to the new build.
  • Keep checkout error rate below 0.5% during the release night.
  • Give compliance approvers concrete evidence before final promotion.
  • Reset safely if payment, identity, or health checks failed.
Solution Using Swap with preview

The release pipeline deployed the new build to the staging slot, then started Swap with preview using Azure CLI. App Service applied target-slot configuration to staging, including production Key Vault references and payment settings, while production continued serving users. Automated smoke tests verified login, payment authorization, tax-form upload, and health endpoints. The pipeline required human approval after the test report, then completed the swap with the CLI action for final promotion. If any check failed, the pipeline ran reset and kept production untouched.

Results & Business Impact
  • Checkout error rate stayed at 0.18% during the deadline release.
  • Release validation time fell from 74 minutes to 28 minutes with scripted evidence.
  • Two bad Key Vault references were caught in preview before traffic moved.
  • Compliance approval used pipeline logs instead of manual screenshots.
Key Takeaway for Glossary Readers

Swap with preview gives release teams a production-like checkpoint before the irreversible part of a slot promotion.

Case study 02

Food delivery platform catches slot setting drift

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A regional food delivery platform ran separate staging and production slots for its merchant portal. A hotfix looked safe in staging, but operators suspected sticky settings had drifted after several emergency patches.

Business/Technical Objectives
  • Detect wrong connection strings before drivers and merchants used the fix.
  • Complete the hotfix within a 45-minute low-traffic window.
  • Avoid a database failover caused by staging traffic hitting production incorrectly.
  • Document the exact slot actions for incident review.
Solution Using Swap with preview

Engineers used Swap with preview from an Azure CLI runbook. They listed slots, compared app settings, and started preview for the staging slot targeting production. During preview, synthetic tests created sample merchant sessions, checked order-status APIs, and verified the app used the intended database and cache endpoints. Logs immediately showed staging still had an old feature flag that would have bypassed a new inventory check. The team reset the preview, fixed the slot setting, restarted preview, reran tests, and then completed the swap.

Results & Business Impact
  • A mis-scoped feature flag was fixed before merchant traffic moved.
  • The hotfix completed in 39 minutes, inside the approved window.
  • No database failover or order-status incident occurred during the release.
  • The post-incident review used CLI command history and test output as evidence.
Key Takeaway for Glossary Readers

Swap with preview is most valuable when configuration drift, not code, is the real release risk.

Case study 03

Utility portal validates authentication before storm season

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

An electric utility updated its outage-reporting portal ahead of storm season. The portal used App Service authentication, private APIs, and strict health probes, making a blind slot swap too risky.

Business/Technical Objectives
  • Verify authentication and private dependency access before customer traffic moved.
  • Keep outage-report submission available during the maintenance window.
  • Reduce release rollback time if the new portal failed health checks.
  • Provide operations leadership with clear go or no-go evidence.
Solution Using Swap with preview

The web team reviewed App Service slot limitations and tested the deployment in a nonproduction environment first. For production, they used a Swap with preview runbook where supported slot settings were applied to staging and smoke tests validated sign-in, outage submission, private API calls, and warm-up endpoints. Network traces and application logs were checked before the final action. When one private endpoint DNS setting failed, operators reset the preview, corrected the configuration, and reran the sequence rather than completing a risky swap.

Results & Business Impact
  • A private DNS error was caught before customers used the new portal.
  • Outage-report availability remained above 99.98% during the maintenance window.
  • Rollback decision time improved from an estimated 30 minutes to under 6 minutes.
  • Leadership received a concise release record with slot, health, and reset evidence.
Key Takeaway for Glossary Readers

Swap with preview helps critical web apps prove readiness under production-like conditions before public traffic is exposed.

Why use Azure CLI for this?

Azure CLI is useful for swap with preview because it supports precise slot operations and repeatable checks. Engineers can list slots, inspect app settings, start the preview action, run health tests, complete the swap, or reset the preview without relying on portal memory. CLI output can be stored with deployment logs and change records. It also reduces mistakes when coordinating multiple apps that must be promoted in order. For App Service teams, the important value is not speed; it is a controlled release sequence where every command identifies the same app, slot, and target. That consistency matters when rollback pressure is high.

CLI use cases

  • List slots for a web app and confirm the source and target before any production-impacting command.
  • Start swap preview from a deployment pipeline and run smoke tests before completing the operation.
  • Reset a preview when validation fails and record the command output in the release log.
  • Inspect slot app settings and connection strings before deciding whether a setting should be sticky.
  • Complete the swap only after health checks, logs, and dependency tests show the previewed slot is safe.

Before you run CLI

  • Confirm tenant, subscription, resource group, app name, source slot, and target slot before running any swap command.
  • Review slot-specific settings, connection strings, authentication, managed identity access, and Key Vault references first.
  • Know whether the app uses site authentication or other settings that limit swap with preview behavior.
  • Have smoke tests, rollback steps, deployment owner approval, and maintenance-window expectations documented before starting preview.
  • Use JSON or table output consistently so release reviewers can confirm the same slot was previewed and completed.

What output tells you

  • Slot list output shows which slots exist and helps prevent swapping the wrong staging or production target.
  • Swap command status indicates whether preview started, completed, reset, or failed for the named app and slot.
  • App-setting output shows which values are present on each slot and which should remain slot-specific.
  • Log and health-check output during preview reveals startup failures, dependency errors, authentication problems, or slow warm-up.
  • Resource identifiers in output help match deployment evidence to the exact subscription, resource group, app, and slot.

Mapped Azure CLI commands

App Service slot swap preview operations

direct
az webapp deployment slot list --name <app-name> --resource-group <resource-group>
az webapp deployment slotdiscoverWeb
az webapp config appsettings list --name <app-name> --resource-group <resource-group> --slot <slot-name>
az webapp config appsettingsdiscoverWeb
az webapp deployment slot swap --name <app-name> --resource-group <resource-group> --slot <slot-name> --target-slot production --action preview
az webapp deployment slotoperateWeb
az webapp deployment slot swap --name <app-name> --resource-group <resource-group> --slot <slot-name> --target-slot production --action swap
az webapp deployment slotoperateWeb
az webapp deployment slot swap --name <app-name> --resource-group <resource-group> --slot <slot-name> --target-slot production --action reset
az webapp deployment slotoperateWeb

Architecture context

As an Azure architect, I view swap with preview as part of the release architecture for App Service workloads. Slots separate deployment from exposure, while preview validates the transition between staging configuration and production behavior. It should be paired with health probes, warm-up endpoints, slot setting discipline, dependency checks, rollback steps, and pipeline gates. The application should tolerate startup under production configuration before traffic moves. Identity, Key Vault references, connection strings, networking, authentication, and feature flags must be designed with slots in mind. The anti-pattern is treating slots as identical copies and discovering during swap that sticky settings or production-only dependencies behave differently.

Security

Security impact is direct because preview applies production-like configuration to a nonproduction slot before the final traffic move. That can expose the staging slot to production secrets, managed identity permissions, authentication settings, or private dependencies. Operators must understand which app settings and connection strings are slot-specific and which are swapped. Access to start, complete, or reset swaps should be limited to trusted release identities. Smoke tests should avoid leaking secrets in logs. Security teams should review authentication settings because some slot-swap scenarios, including site authentication combinations, can constrain preview usage. Treat preview as a production-impacting operation during every release review.

Cost

Swap with preview does not add a separate meter, but deployment slots require App Service plan capacity and can increase operational cost. Staging slots running production-sized code consume resources inside the plan, and warm-up tests may call downstream databases, caches, storage, or APIs. Failed previews can extend release windows and engineer time. On the positive side, preview can prevent expensive outages and emergency rollbacks. FinOps owners should understand how many slots remain active, whether extra scale-out is used during releases, and whether diagnostic logging or synthetic tests create meaningful additional spend during promotion windows during each planned release cost review.

Reliability

Reliability impact is high because swap with preview is designed to catch failures before users see them. It can reveal startup exceptions, missing Key Vault access, wrong connection strings, bad health endpoints, or authentication mismatches while production still serves traffic. Reliability depends on disciplined smoke tests and a clear reset path. Operators should avoid starting preview during unrelated incidents, confirm backup and rollback expectations, and remember that slot swaps are operational changes, not magic transactions. A reliable release pipeline starts preview, waits for warm-up, validates dependencies, completes the swap only on green checks, and records what happened before customer exposure.

Performance

Performance impact appears during warm-up and after the final swap. Preview lets teams measure whether the source slot starts correctly under target configuration before production routing changes. It can expose cold-start delays, slow Key Vault references, exhausted connection pools, cache misses, or dependency latency. The swap itself should be paired with warm-up paths and health checks so traffic is not sent to an app that is still initializing. Operators should compare staging and production response times during preview and avoid completing the swap if p95 latency, error rate, or dependency timing already looks unhealthy before the final traffic move gate.

Operations

Operations teams use swap with preview during planned releases, hotfixes, rollback drills, and incident prevention. They list slots, inspect sticky settings, start preview, run synthetic checks, review logs, complete the swap, or reset if validation fails. Runbooks should define who approves the final action, how long preview may remain open, what smoke tests prove readiness, and what to do when reset does not restore an expected configuration. Operators also document slot names and target slots carefully. In busy estates, automation should prefer IDs or exact names and produce clear JSON output as durable deployment evidence during every production promotion window.

Common mistakes

  • Starting preview against the wrong target slot because production and staging names were assumed instead of verified.
  • Forgetting slot-specific settings and accidentally testing with the wrong connection string or feature flag behavior.
  • Completing the swap without smoke tests after preview starts successfully but before the app is actually healthy.
  • Leaving a preview state unresolved and confusing the next deployment or incident-response team.
  • Treating swap with preview as a complete rollback strategy instead of maintaining backups and reset procedures.