Skip to content
Docs Try Aspire
Docs Try

HostedAgentResourceBuilderExtensions Methods

Class Methods 3 members
Extension methods for adding hosted agent applications to the distributed application model.
AsHostedAgent(IResourceBuilder<T>) Section titled AsHostedAgent(IResourceBuilder<T>) extension IResourceBuilder<T>
Configures the resource to run locally as a Microsoft Foundry hosted agent.
public static class HostedAgentResourceBuilderExtensions
{
public static IResourceBuilder<T> AsHostedAgent<T>(
this IResourceBuilder<T> builder)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder for the compute resource.
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
This method applies in run mode. It configures the resource with the hosted agent responses endpoint, a dashboard command for sending messages to the agent, and OpenTelemetry environment variables expected by the Microsoft Foundry agent server SDK.
var agent = builder.AddProject<Projects.AgentService>("agent")
.AsHostedAgent();
AsHostedAgent(IResourceBuilder<T>, IResourceBuilder<AzureCognitiveServicesProjectResource>, Action<HostedAgentConfiguration>) Section titled AsHostedAgent(IResourceBuilder<T>, IResourceBuilder<AzureCognitiveServicesProjectResource>, Action<HostedAgentConfiguration>) extension IResourceBuilder<T>
Configures the resource to run and publish as a hosted agent in Microsoft Foundry, with full programmatic access to the underlying HostedAgentConfiguration (including Azure SDK-specific options such as tools and content filters).
public static class HostedAgentResourceBuilderExtensions
{
public static IResourceBuilder<T> AsHostedAgent<T>(
this IResourceBuilder<T> builder,
IResourceBuilder<AzureCognitiveServicesProjectResource>? project,
Action<HostedAgentConfiguration>? configure = null)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder for the compute resource.
project IResourceBuilder<AzureCognitiveServicesProjectResource> Optional Microsoft Foundry project resource used for both run and publish mode configuration. When null, an existing Foundry project in the model is reused or a new project is created in publish mode.
configure Action<HostedAgentConfiguration> optional A callback to configure hosted agent deployment options.
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.
The HostedAgentConfiguration.ContainerProtocolVersions setting affects both run and publish mode. Other settings are used in publish mode.
AsHostedAgent(IResourceBuilder<T>, Action<HostedAgentConfiguration>) Section titled AsHostedAgent(IResourceBuilder<T>, Action<HostedAgentConfiguration>) extension IResourceBuilder<T>
Configures the resource to run and publish as a hosted agent in Microsoft Foundry, with full programmatic access to the underlying HostedAgentConfiguration. The Foundry project is resolved automatically in publish mode.
public static class HostedAgentResourceBuilderExtensions
{
public static IResourceBuilder<T> AsHostedAgent<T>(
this IResourceBuilder<T> builder,
Action<HostedAgentConfiguration> configure)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder for the compute resource.
configure Action<HostedAgentConfiguration> A callback to configure hosted agent deployment options.
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.