feat: forward service env to extensions#8936
Conversation
There was a problem hiding this comment.
Pull request overview
This PR forwards service-level env values declared in azure.yaml to extension-provided framework and service-target providers through the gRPC extension contract. It adds an Environment field to the azdext.ServiceConfig proto message, expands the service env map with azd's environment resolver during the forward mapping, and preserves the field on the reverse mapping back into core ServiceConfig. To resolve those values, ExternalFrameworkService and its gRPC registration factory are wired with a *lazy.Lazy[*environment.Environment], replacing the previous empty resolver.
Changes:
- Add
map<string, string> environment = 14toServiceConfig(proto + regeneratedmodels.pb.go) and map it in both directions. - Thread an
*environment.EnvironmentintoExternalFrameworkService(via a lazy env in the gRPCFrameworkService) so serviceenvis expanded before forwarding. - Add tests for mapping round-trips, env expansion, and the new registration wiring, plus a docs note.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
cli/azd/grpc/proto/models.proto |
Adds the environment map field to ServiceConfig. |
cli/azd/pkg/azdext/models.pb.go |
Regenerated proto code for the new field and EnvironmentEntry map type. |
cli/azd/pkg/project/mapper_registry.go |
Expands and maps service env in the forward and reverse ServiceConfig conversions. |
cli/azd/pkg/project/framework_service_external.go |
Adds env field; routes Build/Package through toProtoServiceConfig using the real env resolver. |
cli/azd/internal/grpcserver/framework_service.go |
Injects lazyEnv and resolves the environment in the provider factory. |
cli/azd/pkg/project/*_test.go, cli/azd/internal/grpcserver/framework_service_test.go |
Tests for env mapping, expansion, and registration behavior. |
cli/azd/docs/extensions/extension-framework.md |
Documents that service env is forwarded as ServiceConfig.environment. |
One thing worth resolving before merge: the gRPC registration factory now propagates the environment-load error, which can fail restore/build/package for extension-provided framework services when no environment is selected — inconsistent with the sibling ServiceTargetService registration and the prior empty-resolver behavior.
Files not reviewed (1)
- cli/azd/pkg/azdext/models.pb.go: Generated file
There was a problem hiding this comment.
The proto extension, mapper logic, and test coverage here are solid. One issue to address before merge:
The factory registration in onRegisterRequest propagates lazyEnv.GetValue() errors, which will fail restore/build/package for extension framework services when no environment is selected. The sibling ServiceTargetService (service_target_service.go:125) ignores this error with env, _ := s.lazyEnv.GetValue(), and envResolver(nil) already degrades gracefully (returns "" for every key). This should match that pattern to avoid a behavioral regression.
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
jongio
left a comment
There was a problem hiding this comment.
Prior concern addressed. The lazyEnv error is now correctly ignored (matching ServiceTargetService pattern), with nil guard and test coverage for both the error and happy 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
|
Summary
ServiceConfig.environmentto the extension gRPC contract.azure.yamlenvvalues with the existing azd environment resolver before forwarding them to extension providers.Why
External framework and service target extensions need access to service-specific environment configuration declared in
azure.yaml. Forwarding this data through the extension contract lets extension authors consume the same service-levelenvvalues that core azd can already resolve for built-in service flows.Impact
azdext.ServiceConfig.Environment.envis not configured.Tests
go test ./pkg/project -run "TestServiceConfigMapping|TestServiceConfigReverseMapping|TestServiceConfigRoundTripMapping|TestFromProtoServiceConfigMapping"