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) { // ... }}Parameters
builder IResourceBuilder<T> The resource builder for the compute resource. Returns
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining. Remarks
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.
Examples
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) { // ... }}Parameters
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. Returns
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining. Remarks
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) { // ... }}Parameters
builder IResourceBuilder<T> The resource builder for the compute resource. configure Action<HostedAgentConfiguration> A callback to configure hosted agent deployment options. Returns
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.