Skip to content

Add App Service deployment slot routing based on deployment history#6627

Merged
vhvb1989 merged 20 commits intomainfrom
copilot/vscode-mkxbgxd1-01dk
Jan 31, 2026
Merged

Add App Service deployment slot routing based on deployment history#6627
vhvb1989 merged 20 commits intomainfrom
copilot/vscode-mkxbgxd1-01dk

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

App Service Deployment Slots Support - Phase 1 Foundation

This PR implements the foundational support for Azure App Service deployment slots as outlined in issue #6526. It focuses on intelligent deployment routing based on deployment history and available slots.

🎯 What This PR Does

Adds automatic slot detection and smart deployment logic to azd deploy for App Service targets:

  • First deployment: Deploys to main app + all slots (ensures consistency)
  • Single slot scenario: Automatically deploys to that slot
  • Multiple slots: Prompts user to select target (including main app)
  • No slots: Deploys to main app only (existing behavior)

📝 Changes Made

Core API Methods (cli/azd/pkg/azapi/webapp.go)

  • HasAppServiceDeployments() - Checks deployment history via Azure Web Apps API
  • GetAppServiceSlots() - Retrieves available deployment slots
  • DeployAppServiceSlotZip() - Deploys zip package to specific slot

Service Target Updates (cli/azd/pkg/project/service_target_appservice.go)

  • Updated appServiceTarget to include console for user interaction
  • Modified Deploy() to support multi-target deployment
  • Added determineDeploymentTargets() with intelligent routing logic
  • Comprehensive error handling with target-specific messages
  • Support for AZD_DEPLOY_{SERVICE}_SLOT_NAME environment variable to skip prompts
  • Deployment messages mirror Azure Portal terminology:
    • No slots: "Uploading deployment package"
    • Main app with slots: "Uploading deployment package to production slot"
    • Named slots: "Uploading deployment package to slot 'name'"

Test Coverage

  • Unit tests (cli/azd/pkg/azapi/webapp_slots_test.go):
    • HasAppServiceDeployments (with/without deployments)
    • GetAppServiceSlots (with/without slots)
    • DeployAppServiceSlotZip (success/not found scenarios)
  • Functional test (cli/azd/test/functional/deploy_test.go):
    • Test_CLI_Deploy_SlotDeployment - End-to-end test of slot deployment workflow
    • Uses serviceHealthProber struct with session-aware retry delays
    • Context and testing.T passed as method parameters (not stored in struct)
    • Reuses existing cleanupRg function for resource cleanup

✅ Quality Assurance

  • All unit tests pass (new + existing)
  • Build succeeds
  • Linter clean (golangci-lint)
  • Copyright headers validated
  • Code formatting (gofmt)
  • CodeQL security scan passed (0 alerts)
  • Nil pointer safety checks added
  • Resource cleanup with defer
  • Comprehensive documentation
  • Removed unintended extension file changes
  • Refactored test probe to use session-based delays
  • Optimized struct design (removed ctx and t from state)
  • Code deduplication (reusing existing cleanup function)
  • User-friendly messages matching Azure Portal terminology

🔐 Security

  • No security vulnerabilities found (CodeQL scan)
  • Proper nil pointer checks prevent potential panics
  • Safe resource cleanup prevents file handle leaks

📚 Documentation

Added detailed documentation explaining the deployment strategy:

  • Rationale for deploying to all slots on first deployment
  • Explanation of single vs. multiple slot scenarios
  • User experience considerations for slot selection
  • Environment variable for skipping prompts in CI/CD scenarios

🚀 What's Next (Future Phases)

This PR implements Phase 1 foundation. Future enhancements:

  • Phase 2: CLI flags (--to, --traffic, --status)
  • Phase 3: Traffic management and slot swapping
  • Phase 4: Slot-specific configuration support

🔗 Related Issue

Closes #6526 (Phase 1)

Original prompt

let's use this to fix #6526. Create a PR with the current changes and the context of this conversation.
Do not make changes to /extension folder

[Chronological Review: The conversation began with the user requesting the flow path for running `azd deploy` for a host of `appservice`, specifically looking for a command that calls a manager to invoke the app service implementation with `zipdeploy`. The user then inquired about the logic behind `GetServiceTarget` and how resources are identified for deployment. Following this, the user asked about which `serviceTarget` has a custom resolver and how it operates. The user then shifted focus to updating the app service to utilize a custom resolver, requesting the implementation details for this change. The conversation evolved to discuss deploying app service to slots, with specific conditions for deployment based on previous deployments and slot availability. The user clarified the deployment logic, emphasizing that if there are no previous deployments, the app should be deployed to both the main web app and any slots. The user also requested to create a PR to fix a specific GitHub issue without modifying the `/extension` folder.]

[Intent Mapping:

  1. "find the flow path for running azd deploy for a host=appservice." - User wants to understand the deployment command structure.
  2. "What's the logic behind GetServiceTarget?" - User seeks clarity on resource identification for deployment.
  3. "what serviceTarget has custom resolver?" - User is interested in understanding custom resolvers.
  4. "Can we update appservice to use a custom resolver as well?" - User wants to implement a custom resolver for app service.
  5. "let's directly update the Deploy() implementation for appservice." - User decides to modify the deployment logic instead of using a custom resolver.
  6. "what happens in case of no previous deployments + multiple slots?" - User seeks clarification on deployment behavior in specific scenarios.
  7. "let's do number 2. Deploy to main and all slots." - User confirms the desired deployment strategy.
  8. "let's use this to fix App Service Deployment Slots Support - Phase 1 #6526." - User requests to create a PR with the changes discussed.]

[Technical Inventory:

  • azd deploy: Command for deploying applications.
  • GetServiceTarget: Function for identifying deployment resources.
  • Custom resolver: A mechanism to customize deployment logic.
  • App service slots: Deployment targets for Azure App Services.
  • GitHub issue App Service Deployment Slots Support - Phase 1 #6526: A specific issue related to the discussed changes.]

[Code Archaeology:

  • Deploy(): The main function to be modified for app service deployment logic.
  • New methods to be added:
    • Method to check for previous deployments.
    • Method to retrieve web app slots.]

[Progress Assessment:

  • Completed Tasks: User has outlined the deployment logic and confirmed the approach.
  • Partially Complete Work: Implementation details for the Deploy() method and PR creation are pending.]

[Context Validation: All necessary context for continuing the implementation of the Deploy() method and creating the PR is captured.]

[Recent Commands Analysis:

  • Last Agent Commands: User requested to create a PR with the current changes and context of the conversation, specifying not to modify the /extension folder.
  • Tool Results Summary: No specific tool results were returned as the focus was on planning and outlining changes.
  • Pre-Summary State: The agent was actively discussing the deployment logic for app service and preparing to create a PR.
  • Operation Context: The commands were executed to finalize the deployment strategy and address a specific GitHub issue.]
1. Conversation Overview: - Primary Objectives: - "find the flow path for running azd deploy for a host=appservice." - "What's the logic behind GetServiceTarget?" - "Can we update appservice to use a custom resolver as well?" - "let's use this to fix https://github.com//issues/6526." - Session Context: The conversation flowed from understanding deployment commands to discussing the logic behind deployment strategies and ultimately deciding on modifications to the `Deploy()` method for app service. - User Intent Evolution: The user shifted from exploring custom resolvers to directly modifying the deployment logic based on deployment history and slot availability.
  1. Technical Foundation:
  • azd: Azure Developer CLI for deploying applications.
  • GetServiceTarget: Function for determining the target service for deployment.
  • Custom resolver: A feature to allow custom logic in deployment processes.
  • App service slots: Deployment targets that allow for staging and testing.
  1. Codebase Status:
  • Deploy():
    • Purpose: Main function for deploying the app service.
    • Current State: Logic to be modified to handle deployment based on previous deployments and slot availability.
    • Key Code Segments: N...

Created from VS Code.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 28, 2026 01:06
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
… and fix file handle cleanup

Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix app service deployment logic with custom resolver Add App Service deployment slot routing based on deployment history Jan 28, 2026
Copilot AI requested a review from vhvb1989 January 28, 2026 01:18
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Copilot AI requested a review from vhvb1989 January 28, 2026 18:31
@vhvb1989 vhvb1989 marked this pull request as ready for review January 28, 2026 19:21
Copilot AI review requested due to automatic review settings January 28, 2026 19:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sion-based retry delay

Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
…meters instead

Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
@vhvb1989
Copy link
Member

/azp run azure-dev - cli

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
Copy link
Contributor

@weikanglim weikanglim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, @vhvb1989! I appreciate the effort towards landing this cleanly and in a thoughtful manner. Kudos on making the e2e test readable and demonstrating the overall feature here.

@vhvb1989 vhvb1989 enabled auto-merge (squash) January 30, 2026 21:45
@vhvb1989
Copy link
Member

/check-enforcer evaluate

@vhvb1989 vhvb1989 merged commit 79cfd1b into main Jan 31, 2026
7 checks passed
@vhvb1989 vhvb1989 deleted the copilot/vscode-mkxbgxd1-01dk branch January 31, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App Service Deployment Slots Support - Phase 1

5 participants