Skip to content

fix: reject failed azd environment lookups - #1057

Merged
Roopan-Microsoft merged 1 commit into
microsoft:devfrom
cyberflying:cyberflying-fix-deployment-503
Aug 28, 2026
Merged

fix: reject failed azd environment lookups#1057
Roopan-Microsoft merged 1 commit into
microsoft:devfrom
cyberflying:cyberflying-fix-deployment-503

Conversation

@cyberflying

Copy link
Copy Markdown
Contributor

Purpose

  • Prevent failed azd env get-value calls from writing CLI error text into App Service settings. Invalid USE_SQL values caused Pydantic validation to fail during API startup, leaving the backend unavailable with HTTP 503 responses.
  • Check the azd exit code and normalize output before accepting optional agent settings in both post-provision data paths.

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

What to Check

Verify that the following are valid

  • Missing optional agent keys return an empty value instead of ERROR: key not found....
  • Agent setup and external data connection flows only sync valid settings to the API App Service.
  • The API starts successfully when optional agent keys are initially absent.

Other Information

The failure was reproduced in an Azure deployment and recovery was validated with a healthy API plus successful SQL, Search, and Cosmos checks.

Prevent azd error output from being written into App Service settings when optional agent environment keys are missing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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 hardens the post-provision PowerShell scripts so failed azd env get-value lookups don’t propagate CLI error text into downstream configuration (notably App Service settings), which previously could break API startup.

Changes:

  • Validate azd env get-value success via $LASTEXITCODE before accepting output.
  • Normalize azd output to a trimmed string and reject ERROR:-prefixed results in both post-provision scripts.
  • Minor whitespace cleanup in connect-data.ps1.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
infra/scripts/post-provision/setup-agent.ps1 Adds exit-code checking and output normalization for azd env get-value to avoid syncing error text.
infra/scripts/post-provision/connect-data.ps1 Applies the same azd env get-value hardening (plus small whitespace cleanup).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread infra/scripts/post-provision/connect-data.ps1
Comment thread infra/scripts/post-provision/setup-agent.ps1
MohdRafi-Microsoft added a commit that referenced this pull request Aug 27, 2026
- setup-data.ps1: remove long wait/retry indexing logic added in PR #1044;
  restore pre-PR-1044 simple upload/cleanup flow since App Services keep
  VNet integration regardless of public network toggle. Keep -ResourceGroupName
  param and RG auto-discovery.
- connect-data.ps1, setup-agent.ps1: fix Get-AzdEnvValue error detection
  (align with PR #1057) and only send USE_SQL/agent settings when valid/non-empty
  to avoid Pydantic bool validation crash on API startup.
- nginx.conf: add client_max_body_size to fix 413 errors on manual UI uploads
  proxied through the frontend in private-networking mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Roopan-Microsoft
Roopan-Microsoft changed the base branch from main to dev August 28, 2026 05:22
@MohdRafi-Microsoft

Copy link
Copy Markdown
Contributor

Hey, thanks for the contribution. We've updated the target branch from main to dev to align with our standard branching workflow.

@Roopan-Microsoft
Roopan-Microsoft merged commit d76dd59 into microsoft:dev Aug 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants