-
Notifications
You must be signed in to change notification settings - Fork 330
feat: transfer Foundry provisioning to projects #9133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b62da2b
2ca8c31
9bcc5f3
3271d2b
2253695
c2ba868
aff97c7
7ec2ce6
ff80d3c
06dd903
dc4d638
f7abe46
e64f94b
6bc82b8
b7bd6ca
f5aac0a
89c5aa4
c1f48e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,20 +36,6 @@ func configureExtensionHost(host *azdext.ExtensionHost) { | |
| WithServiceTarget(AiAgentHost, func() azdext.ServiceTargetProvider { | ||
| return project.NewAgentServiceTargetProvider(azdClient) | ||
| }). | ||
| WithProvisioningProvider(project.FoundryProviderName, func() azdext.ProvisioningProvider { | ||
| return project.NewFoundryProvisioningProvider(azdClient) | ||
| }). | ||
| WithValidationCheck(azdext.ValidationCheckRegistration{ | ||
| // Provider-agnostic check: runs before provisioning regardless of the | ||
| // provisioning provider. This matters because the azure.ai.agents | ||
| // extension provisions through its own microsoft.foundry provider, | ||
| // which never triggers the Bicep-only "arm-provision" checks. | ||
| CheckType: azdext.ValidationCheckTypeProvision, | ||
| RuleID: project.ResourceGroupLocationRuleID, | ||
| Factory: func() azdext.ValidationCheckProvider { | ||
| return project.NewResourceGroupLocationCheck(azdClient) | ||
| }, | ||
| }). | ||
| WithProjectEventHandler("preprovision", func(ctx context.Context, args *azdext.ProjectEventArgs) error { | ||
| return preprovisionHandler(ctx, azdClient, args) | ||
| }). | ||
|
|
@@ -68,8 +54,11 @@ func configureExtensionHost(host *azdext.ExtensionHost) { | |
| } | ||
|
|
||
| func preprovisionHandler(ctx context.Context, azdClient *azdext.AzdClient, args *azdext.ProjectEventArgs) error { | ||
| deployments, err := collectProjectDeployments(args.Project.Services) | ||
| if err != nil { | ||
| if err := updateLegacyProjectDeployments( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are "legacy projects"?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By “legacy projects,” I mean existing azure.yaml projects using the older |
||
| ctx, | ||
| azdClient, | ||
| args.Project.Services, | ||
| ); err != nil { | ||
| return err | ||
| } | ||
| connections, err := collectConnections(args.Project.Services) | ||
|
|
@@ -83,7 +72,13 @@ func preprovisionHandler(ctx context.Context, azdClient *azdext.AzdClient, args | |
| if err := populateContainerSettings(ctx, azdClient, svc); err != nil { | ||
| return fmt.Errorf("failed to populate container settings for service %q: %w", svc.Name, err) | ||
| } | ||
| if err := envUpdate(ctx, azdClient, args.Project, svc, deployments, connections); err != nil { | ||
| if err := envUpdate( | ||
| ctx, | ||
| azdClient, | ||
| args.Project, | ||
| svc, | ||
| connections, | ||
| ); err != nil { | ||
| return fmt.Errorf("failed to update environment for service %q: %w", svc.Name, err) | ||
| } | ||
| } | ||
|
|
@@ -168,6 +163,34 @@ func currentEnvName(ctx context.Context, azdClient *azdext.AzdClient) (string, e | |
| return resp.Environment.Name, nil | ||
| } | ||
|
|
||
| func updateLegacyProjectDeployments( | ||
| ctx context.Context, | ||
| azdClient *azdext.AzdClient, | ||
| services map[string]*azdext.ServiceConfig, | ||
| ) error { | ||
| deployments, err := collectLegacyProjectDeployments(services) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if len(deployments) == 0 { | ||
| return nil | ||
| } | ||
|
|
||
| envName, err := currentEnvName(ctx, azdClient) | ||
| if err != nil { | ||
| return fmt.Errorf( | ||
| "resolving environment for legacy deployments: %w", | ||
| err, | ||
| ) | ||
| } | ||
| return deploymentEnvUpdate( | ||
| ctx, | ||
| deployments, | ||
| azdClient, | ||
| envName, | ||
| ) | ||
| } | ||
|
|
||
| // developerRBACOnce ensures CheckDeveloperRBAC runs at most once per extension | ||
| // process lifetime. Service-level predeploy handlers fire per-service, but the | ||
| // RBAC pre-flight check is project-scoped and idempotent — running it once is | ||
|
|
@@ -194,8 +217,11 @@ func predeployHandler(ctx context.Context, azdClient *azdext.AzdClient, args *az | |
| warnDuplicateAgentNames(args.Project) | ||
| }) | ||
|
|
||
| deployments, err := collectProjectDeployments(args.Project.Services) | ||
| if err != nil { | ||
| if err := updateLegacyProjectDeployments( | ||
| ctx, | ||
| azdClient, | ||
| args.Project.Services, | ||
| ); err != nil { | ||
| return err | ||
| } | ||
| connections, err := collectConnections(args.Project.Services) | ||
|
|
@@ -206,7 +232,13 @@ func predeployHandler(ctx context.Context, azdClient *azdext.AzdClient, args *az | |
| if err := populateContainerSettings(ctx, azdClient, svc); err != nil { | ||
| return fmt.Errorf("failed to populate container settings for service %q: %w", svc.Name, err) | ||
| } | ||
| if err := envUpdate(ctx, azdClient, args.Project, svc, deployments, connections); err != nil { | ||
| if err := envUpdate( | ||
| ctx, | ||
| azdClient, | ||
| args.Project, | ||
| svc, | ||
| connections, | ||
| ); err != nil { | ||
| return fmt.Errorf("failed to update environment for service %q: %w", svc.Name, err) | ||
| } | ||
|
|
||
|
|
@@ -477,7 +509,6 @@ func envUpdate( | |
| azdClient *azdext.AzdClient, | ||
| azdProject *azdext.ProjectConfig, | ||
| svc *azdext.ServiceConfig, | ||
| deployments []project.Deployment, | ||
| connections []project.Connection, | ||
| ) error { | ||
|
|
||
|
|
@@ -495,15 +526,6 @@ func envUpdate( | |
| return err | ||
| } | ||
|
|
||
| // Deployments and connections are sourced from the sibling | ||
| // azure.ai.project and azure.ai.connection services. Resources and tool | ||
| // connections stay on the agent service. | ||
| if len(deployments) > 0 { | ||
| if err := deploymentEnvUpdate(ctx, deployments, azdClient, currentEnvResponse.Environment.Name); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| if foundryAgentConfig != nil && len(foundryAgentConfig.Resources) > 0 { | ||
| if err := resourcesEnvUpdate(ctx, foundryAgentConfig.Resources, azdClient, currentEnvResponse.Environment.Name); err != nil { | ||
| return err | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.