# HostedAgentResourceBuilderExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Foundry](/reference/api/csharp/aspire.hosting.foundry.md)
- Version: `13.3.0-preview.1.26254.5`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/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>, Action<HostedAgentConfiguration>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#ashostedagent-iresourcebuilder-t-action-hostedagentconfiguration) : `IResourceBuilder<T>` `extension` `ats ignored` -- In both run and publish modes, build, deploy, and run the containerized agent as a hosted agent in Microsoft Foundry.
- [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` -- In both run and publish modes, build, deploy, and run the containerized agent as a hosted agent in Microsoft Foundry.
- [PublishAsHostedAgent(IResourceBuilder<T>, Action<HostedAgentConfiguration>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#publishashostedagent-iresourcebuilder-t-action-hostedagentconfiguration) : `IResourceBuilder<T>` `extension` `ats ignored` -- Publish the containerized agent as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically.
- [PublishAsHostedAgent(IResourceBuilder<T>, IResourceBuilder<AzureCognitiveServicesProjectResource>, Action<HostedAgentConfiguration>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#publishashostedagent-iresourcebuilder-t-iresourcebuilder-azurecognitiveservicesprojectresource-action-hostedagentconfiguration) : `IResourceBuilder<T>` `extension` `ats export` -- Publish the containerized agent as a hosted agent in Microsoft Foundry. If a project resource is not provided, the method will attempt to find an existing Microsoft Foundry project resource in the application model. If none exists, a new project resource (and its parent account resource) will be created automatically.
- [RunAsHostedAgent(IResourceBuilder<T>, Action<HostedAgentConfiguration>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#runashostedagent-iresourcebuilder-t-action-hostedagentconfiguration) : `IResourceBuilder<T>` `extension` `ats ignored` -- In run mode, build, deploy, and run the containerized agent as a hosted agent in Microsoft Foundry.
- [RunAsHostedAgent(IResourceBuilder<T>, IResourceBuilder<AzureCognitiveServicesProjectResource>, Action<HostedAgentConfiguration>)](/reference/api/csharp/aspire.hosting.foundry/hostedagentresourcebuilderextensions/methods.md#runashostedagent-iresourcebuilder-t-iresourcebuilder-azurecognitiveservicesprojectresource-action-hostedagentconfiguration) : `IResourceBuilder<T>` `extension` `ats ignored` -- In run mode, build, deploy, and run the containerized agent as a hosted agent in Microsoft Foundry.
