Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/azd/extensions/azure.ai.agents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## Unreleased

### Features Added

- `azd ai agent init` now writes each Foundry resource as its own `azure.yaml` service entry instead of bundling everything into the agent service. Model deployments become a single `azure.ai.project` service, each connection becomes an `azure.ai.connection` service, and each toolbox becomes an `azure.ai.toolbox` service, all wired to the agent through `uses:`. The agents extension registers the `azure.ai.project`, `azure.ai.connection`, and `azure.ai.toolbox` service-target hosts itself as no-ops (the resources are created by Bicep at provision time), so only this extension needs to be installed for `azd up`/`azd deploy` to walk the new service entries. Provisioning behavior is unchanged: the agent extension re-sources deployments, connections, and toolboxes from the sibling services when setting provisioning environment variables and creating toolsets, falling back to a pre-split `azure.yaml` that still bundles them on the agent service so existing projects keep provisioning without re-running `init`.

## 0.1.41-preview (2026-06-19)

- [[#8731]](https://github.com/Azure/azure-dev/pull/8731) Improve the post-deploy `Next:` guidance with a stacked layout that puts each command on its own line above its description, adds a blank line between suggestions, and highlights `azd` commands. The new layout applies across deploy, `azd ai agent show`, `init`, and `doctor`. Thanks @therealjohn for the contribution!
Expand Down
11 changes: 10 additions & 1 deletion cli/azd/extensions/azure.ai.agents/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ displayName: Foundry agents (Preview)
description: Ship agents with Microsoft Foundry from your terminal. (Preview)
usage: azd ai agent <command> [options]
# NOTE: Make sure version.txt is in sync with this version.
version: 0.1.41-preview
version: 0.1.42-preview
requiredAzdVersion: ">1.25.2"
dependencies:
- id: azure.ai.inspector
Expand All @@ -22,6 +22,15 @@ providers:
- name: azure.ai.agent
type: service-target
description: Deploys agents to the Foundry Agent Service
- name: azure.ai.project
type: service-target
description: Registers Foundry project service entries so azd up/deploy succeed
- name: azure.ai.connection
type: service-target
description: Registers Foundry connection service entries so azd up/deploy succeed
- name: azure.ai.toolbox
type: service-target
description: Registers Foundry toolbox service entries so azd up/deploy succeed
- name: microsoft.foundry
type: provisioning-provider
description: Provisions a Microsoft Foundry project from azure.yaml without an on-disk infra/ directory
Expand Down
22 changes: 22 additions & 0 deletions cli/azd/extensions/azure.ai.agents/internal/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2933,6 +2933,19 @@ func (a *InitAction) addToProject(ctx context.Context, targetDir string, agentMa
agentConfig.StartupCommand = startupCmd
}

// Each Foundry resource is written as its own azure.yaml service entry, so
// the deployments, connections, and toolboxes move out of the agent config
// into sibling azure.ai.project/connection/toolbox services emitted below.
// The agent keeps its container, resources, tool connections, and startup
// command. The provisioning handlers re-source the moved data from the
// sibling services.
resourceDeployments := agentConfig.Deployments
resourceConnections := agentConfig.Connections
resourceToolboxes := agentConfig.Toolboxes
agentConfig.Deployments = nil
agentConfig.Connections = nil
agentConfig.Toolboxes = nil

var agentConfigStruct *structpb.Struct
if agentConfigStruct, err = project.MarshalStruct(&agentConfig); err != nil {
return fmt.Errorf("failed to marshal agent config: %w", err)
Expand Down Expand Up @@ -2970,6 +2983,15 @@ func (a *InitAction) addToProject(ctx context.Context, targetDir string, agentMa
return fmt.Errorf("adding agent service to project: %w", err)
}

// Emit the sibling Foundry resource services (project + deployments,
// connections, toolboxes) and wire the agent's uses: to them.
if err := emitResourceServices(
ctx, a.azdClient, a.serviceNameOverride,
resourceDeployments, resourceConnections, resourceToolboxes,
); err != nil {
return err
}

fmt.Printf(
"\nAdded your agent as a service entry named '%s' under the file azure.yaml.\n",
a.serviceNameOverride,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,11 @@ func (a *InitFromCodeAction) addToProject(ctx context.Context, targetDir string,
agentConfig.StartupCommand = startupCmd
}

// Move the model deployments out of the agent config into a sibling
// azure.ai.project service, emitted after the agent service below.
resourceDeployments := agentConfig.Deployments
agentConfig.Deployments = nil

var agentConfigStruct *structpb.Struct
var err error
if agentConfigStruct, err = project.MarshalStruct(&agentConfig); err != nil {
Expand Down Expand Up @@ -888,6 +893,15 @@ func (a *InitFromCodeAction) addToProject(ctx context.Context, targetDir string,
return fmt.Errorf("adding agent service to project: %w", err)
}

// Emit the sibling azure.ai.project service carrying the model deployments
// and wire the agent's uses: to it.
agentServiceName := strings.ReplaceAll(agentName, " ", "")
if err := emitResourceServices(
ctx, a.azdClient, agentServiceName, resourceDeployments, nil, nil,
); err != nil {
return err
}

fmt.Printf("\nAdded your agent as a service entry named '%s' under the file azure.yaml.\n", agentName)
return nil
}
Expand Down
123 changes: 91 additions & 32 deletions cli/azd/extensions/azure.ai.agents/internal/cmd/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ func configureExtensionHost(host *azdext.ExtensionHost) {
WithServiceTarget(AiAgentHost, func() azdext.ServiceTargetProvider {
return project.NewAgentServiceTargetProvider(azdClient)
}).
// The Foundry resource hosts written by `azd ai agent init` are owned by
// this extension too, so `azd up`/`azd deploy` can walk them without a
// separate extension per host. They are no-ops today; the resources are
// created by Bicep at provision time.
WithServiceTarget(AiProjectHost, func() azdext.ServiceTargetProvider {
return project.NewResourceServiceTargetProvider(azdClient)
}).
WithServiceTarget(AiConnectionHost, func() azdext.ServiceTargetProvider {
return project.NewResourceServiceTargetProvider(azdClient)
}).
WithServiceTarget(AiToolboxHost, func() azdext.ServiceTargetProvider {
return project.NewResourceServiceTargetProvider(azdClient)
}).
WithProvisioningProvider(project.FoundryProviderName, func() azdext.ProvisioningProvider {
return project.NewFoundryProvisioningProvider(azdClient)
}).
Expand All @@ -62,13 +75,22 @@ 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 {
return err
}
connections, err := collectConnections(args.Project.Services)
if err != nil {
return err
}

for _, svc := range args.Project.Services {
switch svc.Host {
case AiAgentHost:
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); err != nil {
if err := envUpdate(ctx, azdClient, args.Project, svc, deployments, connections); err != nil {
return fmt.Errorf("failed to update environment for service %q: %w", svc.Name, err)
}
}
Expand All @@ -82,18 +104,34 @@ func postprovisionHandler(
azdClient *azdext.AzdClient,
args *azdext.ProjectEventArgs,
) error {
hasAgent := false
for _, svc := range args.Project.Services {
if svc.Host != AiAgentHost {
continue
// Toolboxes live in sibling azure.ai.toolbox services; their connection
// enrichment still needs the project connections (azure.ai.connection
// services) and the agent tool connections.
toolboxes, err := collectToolboxes(args.Project.Services)
if err != nil {
return fmt.Errorf("failed to collect toolboxes: %w", err)
}

if len(toolboxes) > 0 {
connections, err := collectConnections(args.Project.Services)
if err != nil {
return fmt.Errorf("failed to collect connections: %w", err)
}
toolConnections, err := collectAgentToolConnections(args.Project.Services)
if err != nil {
return fmt.Errorf("failed to collect tool connections: %w", err)
}
hasAgent = true

if err := provisionToolboxes(ctx, azdClient, svc); err != nil {
return fmt.Errorf(
"failed to provision toolboxes for service %q: %w",
svc.Name, err,
)
if err := provisionToolboxes(ctx, azdClient, toolboxes, connections, toolConnections); err != nil {
return fmt.Errorf("failed to provision toolboxes: %w", err)
}
}

hasAgent := false
for _, svc := range args.Project.Services {
if svc.Host == AiAgentHost {
hasAgent = true
break
}
}

Expand Down Expand Up @@ -156,6 +194,15 @@ func currentEnvName(ctx context.Context, azdClient *azdext.AzdClient) (string, e
}

func predeployHandler(ctx context.Context, azdClient *azdext.AzdClient, args *azdext.ProjectEventArgs) error {
deployments, err := collectProjectDeployments(args.Project.Services)
if err != nil {
return err
}
connections, err := collectConnections(args.Project.Services)
if err != nil {
return err
}

hasHostedAgentService := false
for _, svc := range args.Project.Services {
if svc.Host != AiAgentHost {
Expand All @@ -165,7 +212,7 @@ 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); err != nil {
if err := envUpdate(ctx, azdClient, args.Project, svc, deployments, connections); err != nil {
return fmt.Errorf("failed to update environment for service %q: %w", svc.Name, err)
}

Expand Down Expand Up @@ -376,7 +423,14 @@ func cleanupAgentSessionState(ctx context.Context, azdClient *azdext.AzdClient,
return !failed
}

func envUpdate(ctx context.Context, azdClient *azdext.AzdClient, azdProject *azdext.ProjectConfig, svc *azdext.ServiceConfig) error {
func envUpdate(
ctx context.Context,
azdClient *azdext.AzdClient,
azdProject *azdext.ProjectConfig,
svc *azdext.ServiceConfig,
deployments []project.Deployment,
connections []project.Connection,
) error {

var foundryAgentConfig *project.ServiceTargetAgentConfig

Expand All @@ -393,28 +447,31 @@ func envUpdate(ctx context.Context, azdClient *azdext.AzdClient, azdProject *azd
return err
}

if len(foundryAgentConfig.Deployments) > 0 {
if err := deploymentEnvUpdate(ctx, foundryAgentConfig.Deployments, azdClient, currentEnvResponse.Environment.Name); err != nil {
// 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 len(foundryAgentConfig.Resources) > 0 {
if foundryAgentConfig != nil && len(foundryAgentConfig.Resources) > 0 {
if err := resourcesEnvUpdate(ctx, foundryAgentConfig.Resources, azdClient, currentEnvResponse.Environment.Name); err != nil {
return err
}
}

if len(foundryAgentConfig.Connections) > 0 {
if len(connections) > 0 {
if err := connectionsEnvUpdate(
ctx, foundryAgentConfig.Connections,
ctx, connections,
azdClient, currentEnvResponse.Environment.Name,
); err != nil {
return err
}
}

if len(foundryAgentConfig.ToolConnections) > 0 {
if foundryAgentConfig != nil && len(foundryAgentConfig.ToolConnections) > 0 {
if err := toolConnectionsEnvUpdate(
ctx, foundryAgentConfig.ToolConnections,
azdClient, currentEnvResponse.Environment.Name,
Expand Down Expand Up @@ -672,22 +729,27 @@ func populateContainerSettings(ctx context.Context, azdClient *azdext.AzdClient,
}

// provisionToolboxes creates or updates Foundry Toolsets for each toolbox
// in the service config. Called during post-provision after the project
// endpoint has been created by Bicep.
// sourced from the sibling azure.ai.toolbox services. Called during
// post-provision after the project endpoint has been created by Bicep. The
// connections and toolConnections are used to resolve connection references
// declared on the toolboxes.
func provisionToolboxes(
ctx context.Context,
azdClient *azdext.AzdClient,
svc *azdext.ServiceConfig,
toolboxes []project.Toolbox,
connections []project.Connection,
toolConnections []project.ToolConnection,
) error {
var config *project.ServiceTargetAgentConfig
if err := project.UnmarshalStruct(svc.Config, &config); err != nil {
return fmt.Errorf("failed to parse service config: %w", err)
}

if config == nil || len(config.Toolboxes) == 0 {
if len(toolboxes) == 0 {
return nil
}

// Build connection lookup for enriching tool entries with server_url/server_label
connByName := toolboxConnectionsByName(&project.ServiceTargetAgentConfig{
Connections: connections,
ToolConnections: toolConnections,
})

currentEnv, err := azdClient.Environment().GetCurrent(
ctx, &azdext.EmptyRequest{},
)
Expand Down Expand Up @@ -751,10 +813,7 @@ func provisionToolboxes(
return fmt.Errorf("loading connection IDs: %w", err)
}

// Build connection lookup for enriching tool entries with server_url/server_label
connByName := toolboxConnectionsByName(config)

for _, toolbox := range config.Toolboxes {
for _, toolbox := range toolboxes {
fmt.Fprintf(
os.Stderr, "Provisioning toolbox: %s\n", toolbox.Name,
)
Expand Down
Loading