Improve agent error handling: prefer Bicep fixes over temporary workarounds#7063
Improve agent error handling: prefer Bicep fixes over temporary workarounds#7063hemarina wants to merge 1 commit intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates MCP prompt documentation used by azd agent mode to prioritize permanent infrastructure changes (Bicep/Terraform) over temporary workarounds when resolving provisioning and troubleshooting errors, aligning agent guidance with issue #6837.
Changes:
- Added an “IMPORTANT” policy section to both prompt docs to establish “infra-first” resolution priority and treat
azresource mutations as a last resort. - Reordered several existing error “solutions” to put Bicep fixes ahead of environment-variable workarounds.
- Added new provisioning error sections (role assignment immutability, Azure OpenAI TPM quota, If-Match precondition failures).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| cli/azd/internal/mcp/tools/prompts/azd_provision_common_error.md | Adds infra-first guidance, reorders solution options, and introduces new common provisioning error sections. |
| cli/azd/internal/mcp/tools/prompts/azd_error_troubleshooting.md | Adds matching infra-first guidance to troubleshooting instructions for agent flows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| USE YOUR TERMINAL TOOL to search for location definitions: | ||
|
|
||
| `grep -r "location" infra/*.bicep infra/**/*.bicep` |
There was a problem hiding this comment.
The grep -r "location" infra/*.bicep infra/**/*.bicep command relies on shell globs (infra/**/*.bicep) that won’t work in many default shells (e.g., bash without globstar) and can also fail if infra/*.bicep doesn’t match anything. Prefer a more portable form like grep -R --include='*.bicep' ... infra (or find ... -name '*.bicep' | xargs grep ...) so the instruction works consistently.
| `grep -r "location" infra/*.bicep infra/**/*.bicep` | |
| `grep -R --include='*.bicep' "location" infra` |
| USE YOUR TERMINAL TOOL to search for location definitions: | ||
|
|
||
| USE YOUR TERMINAL TOOL to verify the change: | ||
| `grep -r "location\|AZURE_LOCATION" infra/*.bicep infra/**/*.bicep` |
There was a problem hiding this comment.
grep -r "location\|AZURE_LOCATION" ... uses \| alternation, which is not portable with basic grep (commonly requires grep -E 'location|AZURE_LOCATION' or multiple -e patterns). Since this is an instruction meant to be executed, switch to an invocation that works across environments.
| `grep -r "location\|AZURE_LOCATION" infra/*.bicep infra/**/*.bicep` | |
| `grep -r -e "location" -e "AZURE_LOCATION" infra/*.bicep infra/**/*.bicep` |
| If the principal ID has intentionally changed and you need to reassign, USE YOUR TERMINAL TOOL to delete the old role assignment first: | ||
|
|
||
| `az role assignment delete --assignee <extracted-email-or-object-id> --role <role-assignment-name> --scope /subscriptions/<extracted-subscription-id>` |
There was a problem hiding this comment.
The suggested az role assignment delete --assignee ... --role ... --scope /subscriptions/<...> is risky and may be incorrect for many failures: role assignments can be at RG/resource scopes, and deleting by filters can remove multiple assignments. Consider instructing to (1) extract and use the exact --scope from the error, (2) list matching assignments to capture the assignment id, then (3) delete via az role assignment delete --ids <assignment-id> to avoid accidental removals.
| az account list-locations --output table | ||
| ``` No newline at end of file | ||
| **Error Pattern:** | ||
| - Contains: `This operation require` and `new capacity in quota Tokens Per Minute` |
There was a problem hiding this comment.
Typo in the error pattern: Azure OpenAI quota errors are typically phrased "This operation requires ..." (with an 's'). Using "require" here makes the pattern less reliable for matching/recognition; consider changing to "requires" (or matching on a shorter stable substring like "This operation requir").
| - Contains: `This operation require` and `new capacity in quota Tokens Per Minute` | |
| - Contains: `This operation requires` and `new capacity in quota Tokens Per Minute` |
| ## Role Assignment Immutable Properties Error | ||
|
|
There was a problem hiding this comment.
PR description says 4 new error sections were added (including “Container App Revision Provision Expired Error”), but this file currently adds only 3 new sections (Role Assignment Immutable Properties, TPM Quota Exceeded, If-Match Precondition Failed). Either add the missing Container App section (with the referenced azd monitor guidance) or update the PR description to match the actual change set.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Summary
Improves agent error handling for provisioning error resolution to prefer permanent infrastructure fixes over temporary workarounds.
Addresses #6837
Changes
azd_provision_common_error.md
azd_error_troubleshooting.md