fix: prompt for subscription and location on foundry azd up#8883
Conversation
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
This PR updates the azure.ai.agents extension’s Foundry provisioning provider so azd up/azd provision behaves like core azd when AZURE_SUBSCRIPTION_ID and/or AZURE_LOCATION are missing: prompt interactively and persist the chosen values to the active azd environment, while still producing deterministic actionable errors under --no-prompt (Fixes #8859).
Changes:
- Update
FoundryProvisioningProvider.resolveEnvto prompt-and-persist subscription/location when missing instead of immediately failing with a dependency error. - Add provider helpers (
promptSubscription,promptLocation,setEnv) to centralize prompt + persistence behavior and preserve--no-promptactionable guidance. - Add focused unit tests for the new resolveEnv prompting behavior and update the extension changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/project/foundry_provisioning_provider.go | Prompts for subscription/location when missing and persists selections to the azd environment. |
| cli/azd/extensions/azure.ai.agents/internal/project/foundry_provisioning_provider_resolveenv_test.go | Adds tests covering prompt-and-persist and --no-prompt / cancellation behaviors for resolveEnv. |
| cli/azd/extensions/azure.ai.agents/CHANGELOG.md | Documents the behavior change for #8859 under “Unreleased”. |
jongio
left a comment
There was a problem hiding this comment.
Solid fix. The prompt-then-persist approach matches the init flow in init_foundry_resources_helpers.go and aligns with core azd up behavior. Error handling (cancellation, prompt-required, generic fallback) follows the established tri-branch pattern correctly.
One gap in test coverage noted below.
jongio
left a comment
There was a problem hiding this comment.
Prior feedback addressed: read-error separation, empty-response validation, and location cancellation test all look correct. CI is green.
One minor coverage nit below (non-blocking).
Adds a new 'Test coverage symmetry' section to go.instructions.md, sourced from recurring reviewer feedback across three PRs (#8883, #8874, #8876). Rule covers three patterns flagged by reviewers: - Symmetric prompt paths (subscription ↔ location: success/error/cancel) - Serialisation round-trip tests (save + reload, not just write direction) - Compound constraint interactions (step-alignment × max-capacity) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes #8859
Problem
Running
azd upin a Foundry (azure.ai.agents) project fails immediately whenAZURE_SUBSCRIPTION_ID(orAZURE_LOCATION) is not set in the azd environment:Core
azd upprompts the user to pick a subscription/location when they aren't set; the extension's provisioning provider instead hard-failed.Root cause
FoundryProvisioningProvider.resolveEnvreadAZURE_SUBSCRIPTION_ID/AZURE_LOCATIONfrom the environment and returned aDependencyerror when either was empty, rather than prompting. The extension already prompts in itsinitflow (PromptSubscription/PromptLocation), but the provision path (azd up/azd provision) never adopted it.Fix
When
AZURE_SUBSCRIPTION_ID/AZURE_LOCATIONare missing,resolveEnvnow prompts via the azdext Prompt service and persists the chosen values to the azd environment, matching coreazd up.promptSubscription/promptLocation/setEnvhelpers on the provider.--no-prompt/ CI behavior preserved: when the host returns a "prompt required" error, the original actionableazd env set ...suggestion is still surfaced.ensureCredential+withTenantOutput).endpoint:) path is untouched — it usesresolveEnvNameand needs no subscription/location.Tests
Added
foundry_provisioning_provider_resolveenv_test.gocovering: prompt-and-persist for both values;--no-promptactionable errors for missing subscription and location; and user-cancellation handling. Fullinternal/projectsuite andgo build ./...pass;gofmt,golangci-lint, andcspellare clean.