Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ await foundry
</TabItem>
</Tabs>

`AddProject` creates a default Azure Container Registry for hosted agents. Use `WithContainerRegistry` when you want to point the project at a different registry.
`AddProject` creates a default Azure Container Registry for hosted agents only in publish mode (when deploying to Azure). In local run mode, no default registry is created. Use `WithContainerRegistry` when you want to point the project at a specific registry.

## Publish a hosted agent to Azure AI Foundry
## Add a hosted agent to Azure AI Foundry

Use `PublishAsHostedAgent` to publish an executable or containerized app as a hosted agent in a Foundry project:
Use `AsHostedAgent` to configure an executable or containerized app as a hosted agent in a Foundry project:

<Tabs syncKey='aspire-lang'>
<TabItem id='csharp' label='C#'>
Expand All @@ -366,13 +366,13 @@ var chat = project.AddModelDeployment("chat", FoundryModel.OpenAI.Gpt5Mini);
builder.AddPythonApp("agent-python", "..\\agent", "main:app")
.WithReference(project)
.WithReference(chat)
.PublishAsHostedAgent(project);
.AsHostedAgent(project);

builder.AddProject<Projects.Agent>("agent-dotnet")
.WithHttpEndpoint(targetPort: 9000)
.WithReference(project)
.WithReference(chat)
.PublishAsHostedAgent(project);
.AsHostedAgent(project);

builder.Build().Run();
```
Expand All @@ -397,22 +397,22 @@ await builder
.addPythonApp('agent-python', '../agent', 'main:app')
.withReference(project)
.withReference(chat)
.publishAsHostedAgent({ project });
.asHostedAgent({ project });
Comment thread
IEvangelist marked this conversation as resolved.
Outdated
Comment thread
IEvangelist marked this conversation as resolved.
Outdated

await builder
.addProject('agent-dotnet', '../Agent/Agent.csproj')
.withHttpEndpoint({ targetPort: 9000 })
.withReference(project)
.withReference(chat)
.publishAsHostedAgent({ project });
.asHostedAgent({ project });
Comment thread
IEvangelist marked this conversation as resolved.
Outdated

await builder.build().run();
```

</TabItem>
</Tabs>

In run mode, `PublishAsHostedAgent(...)` configures a local `http` endpoint for the agent. Aspire first checks whether the resource already has an endpoint named `http`. If that endpoint has a target port, Aspire preserves it. If there is no existing `http` target port, Aspire defaults to `8088`.
In run mode, `AsHostedAgent(...)` configures a local `http` endpoint for the agent. Aspire first checks whether the resource already has an endpoint named `http`. If that endpoint has a target port, Aspire preserves it. If there is no existing `http` target port, Aspire defaults to `8088`.

Aspire also injects the selected port as `DEFAULT_AD_PORT`, so hosted-agent apps can bind to the right port:

Expand All @@ -421,7 +421,7 @@ var port = Environment.GetEnvironmentVariable("DEFAULT_AD_PORT") ?? "8088";
builder.WebHost.UseUrls($"http://+:{port}");
```

If your hosted agent listens on a different port, declare the endpoint before calling `PublishAsHostedAgent(...)`:
If your hosted agent listens on a different port, declare the endpoint before calling `AsHostedAgent(...)`:

<Tabs syncKey="aspire-lang">
<TabItem id="csharp" label="C#">
Expand All @@ -432,7 +432,7 @@ var dotnetWeatherAgent = builder.AddProject<Projects.WeatherAgent_Dotnet>("weath
.WithReference(project).WaitFor(project)
.WithReference(chat).WaitFor(chat);

dotnetWeatherAgent.PublishAsHostedAgent(project);
dotnetWeatherAgent.AsHostedAgent(project);
```

</TabItem>
Expand All @@ -450,7 +450,7 @@ const dotnetWeatherAgent = await builder
.withReference(chat)
.waitFor(chat);

await dotnetWeatherAgent.publishAsHostedAgent({ project });
await dotnetWeatherAgent.asHostedAgent({ project });
Comment thread
IEvangelist marked this conversation as resolved.
Outdated
```

</TabItem>
Expand Down Expand Up @@ -537,7 +537,7 @@ Prompt agents are deployed to Azure AI Foundry even during local development. Lo

## Invoke agents from the Aspire dashboard

Aspire also makes the declared agents easy to try from the dashboard. Prompt agents get a **Send Message** command from `AddPromptAgent(...)`. Hosted agents published with `PublishAsHostedAgent(...)` get a highlighted **Send Message** command that posts to the local `/responses` endpoint, plus dashboard links for `/responses`, `/liveness`, and `/readiness`.
Aspire also makes the declared agents easy to try from the dashboard. Prompt agents get a **Send Message** command from `AddPromptAgent(...)`. Hosted agents configured with `AsHostedAgent(...)` get a highlighted **Send Message** command that posts to the local `/responses` endpoint, plus dashboard links for `/responses`, `/liveness`, and `/readiness`.
Comment thread
IEvangelist marked this conversation as resolved.
Outdated

<ThemeAwareImage
dark={agentSendMessage}
Expand Down
Loading