Skip to content

fix: prompt for subscription and location on foundry azd up#8883

Merged
trangevi merged 4 commits into
mainfrom
hui/fix-azd-up-subscription-prompt
Jun 30, 2026
Merged

fix: prompt for subscription and location on foundry azd up#8883
trangevi merged 4 commits into
mainfrom
hui/fix-azd-up-subscription-prompt

Conversation

@huimiu

@huimiu huimiu commented Jun 30, 2026

Copy link
Copy Markdown
Member

Fixes #8859

Problem

Running azd up in a Foundry (azure.ai.agents) project fails immediately when AZURE_SUBSCRIPTION_ID (or AZURE_LOCATION) is not set in the azd environment:

ERROR: AZURE_SUBSCRIPTION_ID is required but not set in azd environment "foundry-bugbash"
Suggestion: run `azd env set AZURE_SUBSCRIPTION_ID <subscription-id>`

Core azd up prompts the user to pick a subscription/location when they aren't set; the extension's provisioning provider instead hard-failed.

Root cause

FoundryProvisioningProvider.resolveEnv read AZURE_SUBSCRIPTION_ID / AZURE_LOCATION from the environment and returned a Dependency error when either was empty, rather than prompting. The extension already prompts in its init flow (PromptSubscription / PromptLocation), but the provision path (azd up / azd provision) never adopted it.

Fix

When AZURE_SUBSCRIPTION_ID / AZURE_LOCATION are missing, resolveEnv now prompts via the azdext Prompt service and persists the chosen values to the azd environment, matching core azd up.

  • New promptSubscription / promptLocation / setEnv helpers on the provider.
  • Deterministic --no-prompt / CI behavior preserved: when the host returns a "prompt required" error, the original actionable azd env set ... suggestion is still surfaced.
  • User cancellation maps to the cancellation category.
  • Tenant/credential resolution is unchanged (ensureCredential + withTenantOutput).
  • Brownfield (endpoint:) path is untouched — it uses resolveEnvName and needs no subscription/location.

Tests

Added foundry_provisioning_provider_resolveenv_test.go covering: prompt-and-persist for both values; --no-prompt actionable errors for missing subscription and location; and user-cancellation handling. Full internal/project suite and go build ./... pass; gofmt, golangci-lint, and cspell are clean.

Copilot AI review requested due to automatic review settings June 30, 2026 11:09
@github-actions

Copy link
Copy Markdown

📋 Prioritization Note

Thanks for the contribution! The linked issue isn't in the current milestone yet.
Thank you for logging this issue; our team is reviewing it. If you need urgent prioritization, tag @RickWinter and @kristenwomack to let us know.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.resolveEnv to 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-prompt actionable 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 jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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).

@trangevi trangevi merged commit 06d7610 into main Jun 30, 2026
26 checks passed
github-actions Bot added a commit that referenced this pull request Jul 1, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-agents azure.ai.agents extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd up does not prompt subscription ID

4 participants