Always run extensions middleware for provision but skip lifecycle events in preview mode - #6398
Conversation
…ycle events in preview mode
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #6387 where azd provision --preview incorrectly triggered the extension auto-install prompt for custom service targets even when extensions were already installed. The root cause was that the extensions middleware was conditionally skipped in preview mode, preventing extension processes from starting and registering their service target providers before project initialization. The fix ensures extensions middleware always runs while moving the preview mode check to skip only lifecycle event invocation.
Key Changes:
- Extensions middleware now always runs for the provision command, allowing service target provider registration
- Lifecycle events (preprovision/postprovision) are skipped entirely in preview mode rather than passing a preview flag to handlers
- AKS postprovision handler simplified as preview check moved upstream
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cli/azd/cmd/root.go |
Changed extensions middleware from conditional (UseMiddlewareWhen) to unconditional (UseMiddleware) for provision command |
cli/azd/internal/cmd/provision.go |
Refactored to skip Invoke() call entirely in preview mode instead of passing preview flag in event args |
cli/azd/pkg/project/service_target_aks.go |
Removed preview mode check from postprovision handler as it's now handled upstream |
cli/azd/docs/extension-framework.md |
Added documentation note that provision lifecycle events don't fire in preview mode |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes #6387
This PR fixes an issue where running
azd provision --previewwould incorrectly trigger the extension auto-install prompt for custom service targets (e.g.,azure.ai.agent), even when the extension was already installed, and cause the command to not work as expected.The root cause was that the extensions middleware was conditionally skipped when the
--previewflag was set. Without the middleware running, extension processes were never started, meaning their service target providers were never registered in the IoC container via gRPC. WhenprojectManager.Initialize()subsequently calledGetServiceTarget()for a custom host, it failed to resolve the target and threwUnsupportedServiceHostError, triggering the auto-install flow.The fix ensures extensions middleware always runs for the provision command, allowing extensions to register their service target providers before project initialization occurs.
preprovision/postprovision) in preview mode, rather than passing apreviewflag in event argspostprovisionhandler since preview mode check is now handled upstream