fix: read unified azure.yaml in agent run and deploy#9149
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Unifies agent configuration resolution across run, deploy, provision, and synthesis while retaining legacy configuration support.
Changes:
- Resolves
$reffiles and typed service environment values. - Applies normalized configuration across lifecycle paths.
- Adds coverage for referenced services and resource definitions.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
internal/synthesis/synthesizer.go |
Resolves referenced synthesis inputs. |
internal/synthesis/synthesizer_test.go |
Tests referenced synthesis resources. |
internal/project/service_update.go |
Serializes project service updates. |
internal/project/service_target_agent.go |
Uses resolved deploy configuration. |
internal/project/service_target_agent_test.go |
Tests deployment and build resolution. |
internal/project/resource_group_location_check.go |
Resolves referenced brownfield endpoints. |
internal/project/resource_group_location_check_validate_test.go |
Tests referenced endpoint validation. |
internal/project/foundry_provisioning_provider.go |
Resolves provisioning references. |
internal/project/foundry_provisioning_provider_test.go |
Tests referenced Foundry endpoints. |
internal/project/config.go |
Supports toolbox service-name values. |
internal/project/agent_definition.go |
Centralizes effective agent resolution. |
internal/project/agent_definition_test.go |
Tests unified, legacy, and referenced definitions. |
internal/pkg/projectconfig/environment.go |
Loads and normalizes raw service environments. |
internal/pkg/projectconfig/environment_test.go |
Tests typed and referenced environments. |
internal/cmd/run.go |
Applies unified environment values locally. |
internal/cmd/run_test.go |
Tests service environment resolution. |
internal/cmd/resource_services.go |
Resolves referenced Foundry resources. |
internal/cmd/resource_services_test.go |
Tests referenced resource collection. |
internal/cmd/optimize_apply.go |
Rejects updates to referenced definitions. |
internal/cmd/listen.go |
Updates provision and deploy hooks. |
internal/cmd/listen_test.go |
Tests referenced container settings. |
internal/cmd/helpers.go |
Builds resolved local-run context. |
internal/cmd/helpers_test.go |
Tests raw unified environment loading. |
.vscode/cspell.yaml |
Adds the new package name. |
jongio
left a comment
There was a problem hiding this comment.
One question on a behavior change that's outside what the description covers. Everything else (the $ref/unified resolution across run, deploy, provision, and the env precedence handling) reads cleanly and is well covered by tests.
jongio
left a comment
There was a problem hiding this comment.
The new commit restores the hosted-agent session carryover (capture in predeploy, resume in postdeploy) that the first commit had dropped, so my earlier question is resolved. The restored wiring matches what's on main. Approving.
jongio
left a comment
There was a problem hiding this comment.
The new commit swaps the persist/restore state mutation for a per-request service_path override on the container build, package, and publish calls. The server treats it as a one-operation override without touching the stored config, rejects path traversal via filepath.IsLocal, and falls back to protowire unknown fields for wire compatibility. That resolves my earlier question about how the referenced-service path was being carried into the container operations. Re-approving against the latest commit.
jongio
left a comment
There was a problem hiding this comment.
Re-reviewed the runtime-compatibility follow-up commit. The envSliceHasKey change correctly handles Windows case-insensitive env var names via EqualFold while staying case-sensitive elsewhere, and strings.Cut safely skips entries without an '='. Test coverage matches the platform behavior.
There was a problem hiding this comment.
Re-approving on 224fd21. The new commit constrains file-ref resolution to a root-level "$ref" and preserves nested refs, and it tightens the container service path check with symlink resolution that rejects escapes via the nearest existing ancestor. Path validation correctly treats projectConfig.Path as the project directory, and the added tests cover the nested-ref and symlink-escape cases. Verified the removed ConfigContainsFileRef has no remaining references. Go lint/test/build are green.
jongio
left a comment
There was a problem hiding this comment.
Re-reviewed the latest commit (preserve unified agent configuration). The in-place env-var upsert keeps nested $ref entries intact, the azure.yml lookup ordering matches ReadProjectFile's contract, and the legacy config: fallback in ACR derivation is covered by tests. No concerns on the new changes.
jongio
left a comment
There was a problem hiding this comment.
Re-reviewed the session carry-over restoration (predeploy capture + postdeploy resume in listen.go, plus the README section). Wiring is scoped correctly, the endpoint/credential are the same ones gathered for postdeploy, and the opt-in best-effort behavior is intact.
| configuredEnv := map[string]string{} | ||
| for _, entry := range append(defEnv, serviceEnv...) { | ||
| key, value, _ := strings.Cut(entry, "=") | ||
| configuredEnv[key] = value | ||
| } |
| // The released SDK may not know this optional field yet. | ||
| // Unknown fields preserve wire compatibility. |
jongio
left a comment
There was a problem hiding this comment.
Incremental changes look good. The inline-env normalization path, nil-safety on the config structs, and resolving file refs before the brownfield network check all hold up, and the new tests cover the added paths.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Why this change is needed
Azure AI Agents services can now be defined directly in
azure.yaml, under the deprecatedconfig:block, or in local files referenced through$ref. These forms were not resolved consistently across local run, deploy, and provision. As a result, a valid project could lose environment expressions or value types, skip referenced resources, or build from the wrong service directory.What changed
config:, and local$refservice configuration.azure.ymlsupport while retaining compatibility withagent.yamlandagent.ymlprojects.azd ai agent optimize applyreject only root agent-definition references, avoiding writes to the wrong file without blocking unrelated nested references.How it works
azure.yamlorazure.yml, then resolves inline fields, legacyconfig:, and local$refcontent into one effective service configuration.project:directory, the extension passes that directory to core for the container build, package, and publish operation.Why core azd changes are needed
The extension resolves the actual service directory, but core azd owns container build, package, and publish operations. Core reads the service from its cached project configuration, which still contains the unresolved path.
This PR adds an optional
service_pathfield to those container RPCs. Core validates the project-relative path and applies it to a copy of the service configuration for that operation only. This is safer than temporarily rewritingazure.yaml, which could leave stale user configuration after a failed deploy or interfere with concurrent operations. The protobuf bindings and extension framework documentation are updated to keep the RPC contract in sync.Follow-up plan
azd ai agent doctorand next-step guidance using the same resolver, so diagnostics inspect the configuration that runtime commands execute.Testing
From
cli/azd:go test ./internal/grpcserver ./pkg/azdextFrom
cli/azd/extensions/azure.ai.agents:go test ./internal/cmd ./internal/pkg/projectconfig ./internal/project ./internal/synthesisgo build ./...Closes #9151.
Part of #8710.