feat: Add AZD_DEPLOY_{SERVICE}_IGNORE_SLOTS env var to bypass slot deployment#7530
feat: Add AZD_DEPLOY_{SERVICE}_IGNORE_SLOTS env var to bypass slot deployment#7530
Conversation
…ployment
When deploying to an App Service with deployment slots, azd automatically
routes deployments to slots instead of the main app. This prevents users
from deploying directly to the main app in scenarios like dual-branch
pipelines (e.g., one branch deploys to production, another to a staging slot).
This change introduces a per-service environment variable
AZD_DEPLOY_{SERVICE}_IGNORE_SLOTS that, when set to a truthy boolean value,
bypasses all slot detection logic and deploys directly to the main app.
- Takes precedence over AZD_DEPLOY_{SERVICE}_SLOT_NAME with a warning
- Supports all strconv.ParseBool truthy values (true, TRUE, 1, t, T)
- Documented in environment-variables.md alongside the existing SLOT_NAME var
Fixes #7365
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an opt-out mechanism for App Service slot routing in azd deploy by introducing a per-service environment variable that forces deployments to target the main (production) app even when slots exist, addressing scenarios like dual-branch CI pipelines.
Changes:
- Added
AZD_DEPLOY_{SERVICE}_IGNORE_SLOTShandling to bypass slot/deployment-history routing and deploy to the main app. - Added table-driven tests covering the new env var behavior across slot/deployment-history scenarios.
- Documented App Service slot deployment environment variables (including the previously undocumented
AZD_DEPLOY_{SERVICE}_SLOT_NAME).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
cli/azd/pkg/project/service_target_appservice.go |
Adds env var name helper and early-return logic in slot target determination. |
cli/azd/pkg/project/service_target_appservice_test.go |
Adds unit tests for env var name helpers and ignore-slots behavior. |
cli/azd/docs/environment-variables.md |
Documents slot deployment env vars and precedence behavior. |
- Use LookupEnv to distinguish unset vs invalid values, warn on bad booleans - Use console.MessageUxItem with ux.WarningMessage for user-visible warnings instead of log.Printf (which is suppressed unless debug mode is enabled) - Use environment.Key() to normalize service names instead of duplicating logic - Move docs section from "Core Azure Variables" to "General Configuration" near AZD_DEPLOY_TIMEOUT where deployment-related env vars belong - Add test case for invalid boolean value falling back to slot logic Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wbreza
left a comment
There was a problem hiding this comment.
Code Review — PR #7530
✅ What's Working Well
This PR addresses a real pain point (issue #7365) — the implementation is clean, the environment.Key() refactor is a nice DRY improvement, and the test coverage is thorough with 12 table-driven cases covering the important combinations.
🏗️ Architectural Consideration: Require Explicit Targeting When Deployment Slots Exist
When an App Service has deployment slots configured, multiple deployment targets coexist — the main app (serving production traffic) and one or more named slots (e.g., "staging", "preview"). Deploying to the wrong target is a high-stakes mistake. The current routing heuristic in determineDeploymentTargets decides which target receives the deployment by querying Azure-side deployment history (GET .../sites/{app}/deployments). Because this history is created by any tool — not just azd — the routing behavior can change based on actions taken entirely outside of azd.
This PR adds IGNORE_SLOTS to let users opt out of that heuristic, which brings the interface to three interacting layers:
| Layer | Mechanism |
|---|---|
| Implicit history-based heuristic | Queries Azure-side deployment records to decide routing |
AZD_DEPLOY_{SERVICE}_SLOT_NAME |
Overrides heuristic for multi-slot selection |
AZD_DEPLOY_{SERVICE}_IGNORE_SLOTS (new) |
Overrides heuristic AND takes precedence over SLOT_NAME |
Recommendation: Rather than adding override layers, consider making deployment targeting explicit:
- Interactive mode: When slots exist, always prompt the user with available targets — including the main app (which Azure Portal labels "Production").
- Non-interactive / CI mode (
--no-prompt): When slots exist andSLOT_NAMEis not set, fail the deploy operation with a clear error listing available targets.
| Scenario | Behavior |
|---|---|
| No slots configured | Deploy to the app (single target) |
Slots exist, SLOT_NAME set |
Deploy to the specified target |
Slots exist, no SLOT_NAME (interactive) |
Prompt with available targets (including "production") |
Slots exist, no SLOT_NAME (--no-prompt) |
Fail: "Deployment slots detected. Set AZD_DEPLOY_{SERVICE}_SLOT_NAME to specify the target. Available: production, staging, preview" |
This approach eliminates the need for IGNORE_SLOTS entirely — every deployment is deterministic, CI pipelines fail fast on ambiguous config, and the existing SLOT_NAME env var handles all targeting via a single, well-understood interface. Accepting production as a recognized SLOT_NAME value aligns with the terminology Azure developers already see in the Portal.
I'd love to set up some time with the team to discuss these alternatives and find the right path forward together.
Overall Assessment: Request changes — I'd like to explore the alternative approaches outlined above before committing to this direction. Happy to meet with the team to align on the best path forward.
jongio
left a comment
There was a problem hiding this comment.
The doc comment for determineDeploymentTargets (above the diff) documents the full strategy matrix but doesn't mention the new IGNORE_SLOTS override, which is now the highest-precedence exit path. Worth adding a bullet so the doc stays in sync.
Clean implementation - good use of LookupEnv, environment.Key() DRY-up, and thorough test matrix.
- Add IGNORE_SLOTS override as first bullet in determineDeploymentTargets doc comment so it documents the highest-precedence exit path - Assert warning messages in tests for OverridesSlotName and InvalidValue cases to catch regressions that silently drop WarningMessage output Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
|
Looks good to me. |
Revisiting the Design:
|
… slot deployment (Azure#7530)" This reverts commit 12b5af3.
…ifecycle docs - Sync environment-variables.md to comprehensive upstream reference (PR Azure#7530): adds Core Azure Variables, Dev Center Variables, App Service Slot Deployments, Extension/Alpha/Auth/Tool/CI/CD/Debug/Test variable sections - Document breaking change from PR Azure#7536: AiModel.lifecycle_status is now deprecated (always empty); callers should use AiModelVersion.lifecycle_status - Document that AiModelFilterOptions.statuses now filters on version-level lifecycle status before aggregation - Document that deprecated model versions and SKUs are automatically excluded Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Fixes #7365
When deploying to an App Service that has deployment slots,
azd deployautomatically routes deployments to slots instead of the main app. This prevents users from deploying directly to the main app in scenarios like dual-branch CI pipelines where one branch should deploy to production and another to a staging slot.Changes
Introduces a new per-service environment variable
AZD_DEPLOY_{SERVICE}_IGNORE_SLOTSthat, when set to a truthy boolean value (true,1,TRUE, etc.), bypasses all slot detection logic and deploys directly to the main app.Behavior
IGNORE_SLOTS=trueAZD_DEPLOY_{SERVICE}_SLOT_NAME(with a warning log){SERVICE}naming convention (uppercase, hyphens → underscores)env.Getenv()(supports both azd.envfile and system env vars)Files Changed
cli/azd/pkg/project/service_target_appservice.go— AddedignoreSlotsEnvVarNameForService()helper and early-return check indetermineDeploymentTargetscli/azd/pkg/project/service_target_appservice_test.go— 12 new table-driven tests covering all combinations of env var states, slot counts, and deployment historycli/azd/docs/environment-variables.md— Added new "App Service Slot Deployments" subsection documenting bothAZD_DEPLOY_{SERVICE}_IGNORE_SLOTSand the previously-undocumentedAZD_DEPLOY_{SERVICE}_SLOT_NAMEFollow-up
A separate issue will be created to track updating the official docs (learn.microsoft.com) with slot deployment behavior and the new env var.