Repository navigation
Enable extensions to participate in infra generate - #10931
Richard Park (richardpark-msft) wants to merge 25 commits into
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). 25 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
(NOTE for reviewers: I'm doing this as part of several PRs, so this'll just be the base of the stack) |
There was a problem hiding this comment.
🟡 Changes recommended
Critical overwrite bugs can replace customized manifests without --force and cause colliding resource entries to overwrite each other’s infrastructure, leaving both entries referencing the second entry’s files.
8 open issues
Check all generated-file collisions and preserve the overwrite choice · New Reject duplicate output paths before running generators · New Export the saved AI deployments location parameter mapping · New Return an error from factories backed by a closed broker · New Cancel the gRPC stream on close and reset broker state · New Use the resolved project path for reading and saving · New Clean explicit output paths before validating them · New Allow named flat infrastructure entries in the top-level fallback · New
What changed in this PR
Enables extensions to participate in azd infra generate, separating source generation from provisioning and allowing azure.resources projects to transition to editable Bicep files.
Changes:
- Adds a beta-only generation contract, SDK registration, and authenticated host routing.
- Activates configured generators and validates and saves their replacement infrastructure entries.
- Implements resources-to-Bicep export, with overwrite handling, path protections, tests, and documentation.
Extension user-contract review: blocked — 14 extension files inspected; 0 new contract comments; existing-thread history was not supplied.
| File | Description |
|---|---|
docs/reference/feature-status.md |
Records infrastructure generation as beta-only. |
docs/guides/creating-an-extension.md |
Explains generation-provider registration and responsibilities. |
docs/architecture/extension-framework.md |
Adds generation capability and service documentation. |
cli/azd/pkg/project/infra_generation.go |
Coordinates generators and saves replacement entries. |
cli/azd/pkg/project/infra_generation_test.go |
Covers validation, persistence, cancellation, and edit preservation. |
cli/azd/pkg/project/importer.go |
Adds a comment directing extension generation to the new manager. |
cli/azd/pkg/extensions/validate_registry.go |
Recognizes the generation capability. |
cli/azd/pkg/extensions/resolution.go |
Maps generation capability to its provider type. |
cli/azd/pkg/extensions/resolution_test.go |
Tests capability and provider-type matching. |
cli/azd/pkg/extensions/registry.go |
Defines generation capability and provider-type constants. |
cli/azd/pkg/azdext/service_target_preview_manager_test.go |
Reuses the host receiver lifecycle helper. |
cli/azd/pkg/azdext/provider_registry.go |
Adds synchronized provider registration and lookup. |
cli/azd/pkg/azdext/provider_registry_test.go |
Tests duplicate handling, rollback, and concurrency. |
cli/azd/pkg/azdext/provider_manifest.go |
Includes generators in manifest-registration checks. |
cli/azd/pkg/azdext/infra_generation_manager.go |
Registers SDK generators and dispatches requests. |
cli/azd/pkg/azdext/infra_generation_envelope.go |
Adapts generation messages to the stream broker. |
cli/azd/pkg/azdext/extension_host.go |
Integrates generators into host registration and lifecycle. |
cli/azd/pkg/azdext/extension_host_lifecycle_test.go |
Tests readiness, registration, and cleanup paths. |
cli/azd/pkg/azdext/contracts/v1beta/infra_generation.pb.go |
Adds generated beta message bindings. |
cli/azd/pkg/azdext/contracts/v1beta/infra_generation_grpc.pb.go |
Adds generated beta service bindings. |
cli/azd/pkg/azdext/beta_service_event_manager_test.go |
Checks beta event broker cleanup. |
cli/azd/pkg/azdext/azd_client.go |
Exposes the beta generation client. |
cli/azd/internal/grpcserver/versioned_services.go |
Supplies the native beta generation implementation. |
cli/azd/internal/grpcserver/versioned_services_test.go |
Verifies beta generation service registration. |
cli/azd/internal/grpcserver/versioned_services_generated.go |
Adds generated beta-only registration logic. |
cli/azd/internal/grpcserver/server.go |
Accepts and stores the generation service. |
cli/azd/internal/grpcserver/server_test.go |
Updates fixtures and checks beta-only exposure. |
cli/azd/internal/grpcserver/provider_stream_registry.go |
Tracks provider ownership by stream. |
cli/azd/internal/grpcserver/provider_stream_registry_test.go |
Tests ownership, release, and concurrent registration. |
cli/azd/internal/grpcserver/prompt_service_test.go |
Supplies the generation service in server setup. |
cli/azd/internal/grpcserver/project_service_beta_e2e_test.go |
Updates the server fixture for the new dependency. |
cli/azd/internal/grpcserver/infra_generation_service.go |
Authorizes generators and forwards generation requests. |
cli/azd/internal/grpcserver/infra_generation_service_test.go |
Tests authorization, registration, cleanup, and SDK routing. |
cli/azd/internal/grpcserver/beta_event_service_test.go |
Updates the event server fixture. |
cli/azd/internal/grpcserver/account_service_test.go |
Updates the account server fixture. |
cli/azd/internal/cmd/service_event_messages_graph_test.go |
Updates the command graph server fixture. |
cli/azd/grpc/README.md |
Documents the beta generation protocol. |
cli/azd/grpc/proto/azd/extensions/v1beta/infra_generation.proto |
Defines generation registration, requests, and responses. |
cli/azd/extensions/registry.schema.json |
Allows generation capability and provider declarations. |
cli/azd/extensions/microsoft.azd.extensions/tools/proto-generator/Dockerfile |
Adds architecture fallback and explicit script permissions. |
cli/azd/extensions/extension.schema.json |
Adds generation-provider manifest authoring support. |
cli/azd/extensions/azure.resources/README.md |
Documents Bicep export and supported entry layouts. |
cli/azd/extensions/azure.resources/main_test.go |
Checks both declared resources provider types. |
cli/azd/extensions/azure.resources/internal/resources/layers_test.go |
Uses the shared synthesis function. |
cli/azd/extensions/azure.resources/internal/resources/extension.go |
Refactors synthesis into GenerateFromConfig. |
cli/azd/extensions/azure.resources/internal/resources/extension_test.go |
Updates synthesis tests for the function API. |
cli/azd/extensions/azure.resources/internal/provider/provider.go |
Reuses shared synthesis during provisioning. |
cli/azd/extensions/azure.resources/internal/provider/provider_test.go |
Updates provider fixtures after the synthesis refactor. |
cli/azd/extensions/azure.resources/internal/provider/generation.go |
Writes exported sources and returns a Bicep replacement. |
cli/azd/extensions/azure.resources/internal/provider/generation_test.go |
Tests export, overwrite protection, validation, and path safety. |
cli/azd/extensions/azure.resources/internal/cmd/root.go |
Registers the resources generation provider. |
cli/azd/extensions/azure.resources/extension.yaml |
Declares the generation capability and provider. |
cli/azd/docs/extensions/extension-sdk-reference.md |
Documents the generation SDK and lifecycle contract. |
cli/azd/docs/extensions/extension-framework.md |
Explains activation and generation-provider behavior. |
cli/azd/docs/extensions/contract-versioning.md |
Lists generation among native beta-only services. |
cli/azd/cmd/middleware/middleware_test.go |
Updates expected listener capabilities. |
cli/azd/cmd/middleware/extensions.go |
Includes generation in listener capability selection. |
cli/azd/cmd/middleware/extensions_start_test.go |
Updates the middleware server fixture. |
cli/azd/cmd/middleware/extension_activator.go |
Supports on-demand generator activation. |
cli/azd/cmd/middleware/extension_activator_test.go |
Tests generator selection, reuse, startup, and shutdown. |
cli/azd/cmd/infra_generate.go |
Routes generation through the manager and revises overwrite handling. |
cli/azd/cmd/infra_generate_test.go |
Updates action, flag, and overwrite-confirmation tests. |
cli/azd/cmd/infra_generate_extension_test.go |
Tests command-level generator activation and delegation. |
cli/azd/cmd/extension_action_test.go |
Updates the extension action server fixture. |
cli/azd/cmd/container.go |
Registers the generation manager and gRPC service. |
Review effort: Max
There was a problem hiding this comment.
🟡 Changes recommended
Filesystem-equivalent destinations can bypass collision checks and overwrite exports with --force, while an overlong test comment will fail the configured lint check.
2 open issues
8 resolved since last review
Reject duplicate output paths before running generators Check all generated-file collisions and preserve the overwrite choice Allow named flat infrastructure entries in the top-level fallback Clean explicit output paths before validating them Use the resolved project path for reading and saving Cancel the gRPC stream on close and reset broker state Return an error from factories backed by a closed broker Export the saved AI deployments location parameter mapping
Review effort: Max
|
Updated with some more code coverage - CI was passing, but we fell beneath the threshold for the azdext package. |
There was a problem hiding this comment.
🔵 Needs a closer look
The architecture documentation describes a nonexistent completion callback and incorrectly assigns configuration updates to extensions rather than core, misleading implementers about the generation lifecycle.
Review effort: Max
There was a problem hiding this comment.
🟡 Changes recommended
The declared minimum azd version permits hosts without InfraGenerationService, where mandatory registration prevents the extension from starting and breaks existing resources provisioning.
7 open issues
Raise the minimum azd version for infra generation support · New Raise the minimum azd version or make generator registration optional · New Require azd 1.40.0 for infrastructure generation support Synchronize dependency container access across services Preserve or document the removed --layer flag contract · New Update the stale azd 1.38.0 target · New Document startup timeout behavior for listeners and on-demand providers
1 resolved since last review
Review effort: Max
| Generation uses the beta-only `infra-generation-provider` capability and requires | ||
| an azd host and SDK containing `InfraGenerationService` (target azd 1.38.0). | ||
| This extension's local SDK replacement supports development before that release. | ||
| Pin a published SDK containing the API before publishing the extension. |
| host.WithProvisioningProvider("resources", func() azdext.ProvisioningProvider { | ||
| return resourcesProvider | ||
| }) | ||
| host.WithBetaInfraGenerationProvider("resources", provider.NewGenerationProvider()) |
| // Validate the existing project before prompting for a layer name. | ||
| initialProject, err := parseProject(current, defaultResourcesLayer) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if !cmd.Flags().Changed("layer") { | ||
| layerName := initialProject.resourcesLayer | ||
| if layerName == "" { |
| | Extension usage telemetry (`TelemetryService.ReportUsage`) | Stable v1 | azd 1.36.0 | Deprecated; wire route retained | | ||
| | Current Azure principal (`AccountService.GetCurrentPrincipal`) | Stable v1 | azd 1.36.0 | Deprecated; wire route retained | | ||
| | Deployment preview (`ServiceTargetService.Stream`) | Stable v1 | azd 1.37.0 | Preview messages/fields deprecated; wire route and Go SDK compatibility retained | | ||
| | Infrastructure generation (`InfraGenerationService.Stream`) | Beta-only | — | Native beta service, target azd 1.38.0 | |
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.
Still open (7)
- 🔴 cli/azd/extensions/azure.resources/internal/cmd/root.go#L51 — This registration also runs during ordinary provisioning, but the manifest still allows azd…
- 🔴 cli/azd/extensions/azure.resources/README.md#L146 — azd 1.38.0 has already shipped without
InfraGenerationService(this branch is1.40.0-beta.1),… - 🔴 cli/azd/extensions/azure.resources/extension.yaml#L14 — azd 1.38.x and 1.39.x satisfy the manifest but lack the newly added
InfraGenerationService.… - 🔴 cli/azd/internal/grpcserver/infra_generation_service.go#L125 —
azure.resourcesregisters generation and provisioning providers concurrently, and their separate… - 🟠 cli/azd/extensions/azure.resources/internal/cmd/add.go#L58 — <!-- extension-user-contract-changes-reviewer --> User contract change This change removes the…
- 🔵 docs/reference/feature-status.md#L91 — The "target azd 1.38.0" note is already out of date. azd 1.38.0 shipped on 2026-11-11 without…
- 🔵 cli/azd/docs/environment-variables.md#L212 — The command does not always continue after an extension startup timeout:
ExtensionActivator…
|
(working out some issue with a merge, moving back to draft) |
…e non-production infra gen service first.
Also, adding in a fixed Dockerfile for when you're not using buildkit. There's another PR with this in there, so it'll eventually disappear.
…ore work - I've added TODOs for the bits I'm going to revisit.
- Restoring the old code path that was used for the "legacy" generation (really, just the non-extension based). So the older `resources` code path, and Aspire. I'd alrady split the code out, so it doesn't have to do double-duty (new and old paths) anymore. - Clean paths before we use them, so relative paths, etc... are okay if they combine in a valid way. - Check output paths so they don't collide. - Use the proper method (ProjectPath), don't assume azure.yaml - Also, refactoring to be a bit more obvious about the split between "using our older generators" and the extension based generation that is...THE FUTURE!
… should not use it for.
…o start we should make sure we close it. Without this the extension can just continue on, untracked.



Extensions, like
azure.resourcesneed to be able to generate infra (viaazd infra generate). For resources, especially, this is a key step for users - it's how they go from the simplified resources they've been using to the more advanced scenarios, where they want to dive into the bicep.Currently infra gen only works against it's own internal sources, so this PR makes it so you can register an infra gen provider-equivalent, and get called when the user calls
infra generate.