# HostedAgentResourceBuilderExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Foundry](/reference/api/csharp/aspire.hosting.foundry.md)
- Version: `13.4.0-preview.1.26281.18`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs)

Extension methods for adding hosted agent applications to the distributed application model.

## Definition

```csharp
namespace Aspire.Hosting;

public static class HostedAgentResourceBuilderExtensions
{
    // ...
}
```

## Methods

- [AsHostedAgent(IResourceBuilder<T>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#ashostedagent-iresourcebuilder-t) : `IResourceBuilder<T>` `extension` `ats ignored` -- Configures the resource to run locally as a Microsoft Foundry hosted agent.
- [AsHostedAgent(IResourceBuilder<T>, IResourceBuilder<AzureCognitiveServicesProjectResource>, Action<HostedAgentConfiguration>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#ashostedagent-iresourcebuilder-t-iresourcebuilder-azurecognitiveservicesprojectresource-action-hostedagentconfiguration) : `IResourceBuilder<T>` `extension` `ats ignored` -- Configures the resource to run and publish as a hosted agent in Microsoft Foundry, with full programmatic access to the underlying [HostedAgentConfiguration](/reference/api/csharp/aspire.hosting.foundry/hostedagentconfiguration.md) (including Azure SDK-specific options such as tools and content filters).
- [AsHostedAgent(IResourceBuilder<T>, Action<HostedAgentConfiguration>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#ashostedagent-iresourcebuilder-t-action-hostedagentconfiguration) : `IResourceBuilder<T>` `extension` `ats ignored` -- Configures the resource to run and publish as a hosted agent in Microsoft Foundry, with full programmatic access to the underlying [HostedAgentConfiguration](/reference/api/csharp/aspire.hosting.foundry/hostedagentconfiguration.md). The Foundry project is resolved automatically in publish mode.
