Extension Framework - add allowed_locations to PromptLocation and improve AI model capacity resolution#7397
Conversation
…city resolution Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances the azd extension framework and AI model deployment prompting by (1) adding location allow-list filtering to the PromptLocation gRPC API and (2) making AI model deployment capacity resolution quota-aware so deployments can fall back to a valid capacity that fits remaining quota.
Changes:
- Add
allowed_locationstoPromptLocationRequestand wire it through to prompt selection. - Filter prompted locations based on an allow-list (case-insensitive) and improve the “default location not found” error message.
- Introduce quota-aware capacity resolution (
ResolveCapacityWithQuota) and integrate it into deployment resolution and gRPC prompting flows; update AI locations listing to return AI Services-supported regions.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/pkg/prompt/prompt_service.go | Adds AllowedValues plumbing and location filtering helpers for PromptLocation. |
| cli/azd/pkg/prompt/prompt_service_test.go | Adds unit tests covering allowed-location filtering and default-filtered-out behavior in no-prompt mode. |
| cli/azd/grpc/proto/prompt.proto | Extends PromptLocationRequest with allowed_locations. |
| cli/azd/pkg/azdext/prompt.pb.go | Regenerated protobuf bindings to include AllowedLocations. |
| cli/azd/pkg/ai/model_service.go | Adds quota-aware capacity resolution and updates AI Services location listing + quota-aware filtering logic. |
| cli/azd/pkg/ai/model_service_test.go | Adds unit tests for ResolveCapacityWithQuota. |
| cli/azd/internal/grpcserver/prompt_service.go | Passes allowed locations into prompter and applies quota-aware capacity resolution in AI deployment prompting + SKU candidate filtering. |
| cli/azd/internal/grpcserver/prompt_service_test.go | Adds tests ensuring allowed locations are forwarded and quota fallback behavior is accepted in SKU candidates. |
jongio
left a comment
There was a problem hiding this comment.
PR Review - #7397
Extension Framework - add allowed_locations to PromptLocation and improve AI model capacity resolution by @JeffreyCA
Summary
What: Adds location filtering to the PromptLocation gRPC API via a new allowed_locations field, and introduces quota-aware capacity resolution that falls back to lower capacity values when the default exceeds remaining quota.
Why: Extensions need to restrict which Azure locations are offered during prompts (#7351), and AI model deployments should handle quota constraints gracefully instead of failing at the Azure API level.
Assessment: Solid implementation overall. The location filtering is clean and well-integrated. The quota-aware capacity resolution handles DeepSeek-style SKUs (step=0, large default) well. Main concern is a step-alignment inconsistency between ResolveCapacity and the new capacityFitsWithinQuota - they use different algorithms to validate step alignment, which could produce conflicting results for certain SKU configurations.
Findings
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Logic | 0 | 0 | 1 | 0 |
| Tests | 0 | 0 | 1 | 0 |
| Error Handling | 0 | 0 | 0 | 1 |
| Total | 0 | 0 | 2 | 1 |
Test Coverage Estimate
- Well covered:
ResolveCapacityWithQuota(5 cases),PromptLocationwith allowed locations,buildSkuCandidatesForVersionDeepSeek fallback - Gaps: case-insensitive matching in
filterLocationOptions, interactive path withAllowedLocations,MinCapacitynot aligned toCapacityStep
What's Done Well
filterLocationOptionscorrectly clones before mutating withslices.DeleteFunc- Backward-compatible proto addition
ListLocationsnarrowing to AI-supported regions is a good UX improvement- DeepSeek-style SKU test case covers a real-world edge case
3 inline comments below.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
jongio
left a comment
There was a problem hiding this comment.
Reviewed all 8 changed files across the 2 new commits (834d6bd, 612ef64) since my previous review. All 3 findings are addressed:
- Step alignment inconsistency: fixed via shared
capacityValidForSkuhelper - bothResolveCapacityandcapacityFitsWithinQuotanow use the same validation logic. - Case-insensitive matching:
strings.EqualFoldapplied to all 3 comparison sites, with test coverage. - Empty allowed values: returns original locations instead of nil, with test.
The helper extraction (capacityStepBaseline, minimumValidCapacity, fallbackCapacityWithinQuota) is clean and the DeepSeek-style SKU (step=0, large default) fallback works correctly. LGTM.
…nd document KeyVaultResolver
Sync docs from upstream Azure/azure-dev main and add missing documentation
for new Extension SDK helpers merged in the last 24 hours:
- Add extension-sdk-reference.md: comprehensive API reference for all
azdext SDK helpers including new sections for:
- Process Management helpers (IsProcessRunning, GetProcessInfo, etc.)
- Environment Loading helpers (LoadAzdEnvironment, ParseEnvironmentVariables)
- Project Resolution helpers (GetProjectDir, FindFileUpward)
- Security Validation helpers (ValidateServiceName, ValidateScriptName, etc.)
- SSRF Guard (NewSSRFGuard, DefaultSSRFGuard with fluent builder)
- Testing Helpers (CaptureOutput)
- Key Vault Secret Resolution (KeyVaultResolver, IsSecretReference,
ParseSecretReference, KeyVaultResolveError) -- from PR Azure#7043
- Add extension-e2e-walkthrough.md: end-to-end guide for building an
extension from scratch
- Add extension-migration-guide.md: migration guide from pre-SDK patterns
to new azdext helpers
- Update extension-framework.md: sync latest content including
allowed_locations for PromptLocation and quota-aware capacity resolution
from PR Azure#7397
Related PRs: Azure#7025, Azure#7043, Azure#7397
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Document azd auth token raw token default output (Azure#7384) - Add Key Vault Secret Resolution section for extension SDK (Azure#7043) - Update PromptLocation to include allowed_locations filter (Azure#7397) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributes to #7351
This PR adds location filtering support to the
PromptLocationgRPC API and improves AI model deployment capacity resolution to be quota-aware, falling back to lower capacity values when the default exceeds remaining quota.Changes
Location filtering (
PromptLocation)allowed_locationsfield toPromptLocationRequestin the proto/gRPC API, enabling extensions to restrict which Azure locations are offered during prompts.filterLocationOptionsinprompt_service.gowith case-insensitive matching to filter the location list before prompting or applying defaults.Quota-aware capacity resolution (
ResolveCapacityWithQuota)ResolveCapacityWithQuotainpkg/ai/model_service.go— when no explicit capacity is preferred and the default exceeds remaining quota, it falls back to the highest valid capacity that fits within SKU constraints (min, max, step) and remaining quota.PromptAiDeployment,buildSkuCandidatesForVersion,resolveDeployments,modelHasQuota, andmaxModelRemainingQuota.AI Services location listing
ListLocationsnow queries resource SKU locations (GetResourceSkuLocations) for AIServices/S0 instead of returning all subscription locations, ensuring only AI-supported regions are returned.Testing
ResolveCapacityWithQuotacovering default fits, fallback, step alignment, explicit preferred exceeding quota, and below-minimum scenarios.PromptLocationwithAllowedLocationsand for default-filtered-out error path.buildSkuCandidatesForVersionverifying fallback capacity with DeepSeek-style SKUs (step=0, large default).