# FoundryExtensions

- 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/FoundryExtensions.cs)

Provides extension methods for adding the Microsoft Foundry resources to the application model.

## Definition

```csharp
namespace Aspire.Hosting;

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

## Methods

- [AddDeployment(IResourceBuilder<FoundryResource>, string, string, string, string)](/reference/api/csharp/aspire.hosting.foundry/foundryextensions/methods.md#adddeployment-iresourcebuilder-foundryresource-string-string-string-string) : `IResourceBuilder<FoundryDeploymentResource>` `extension` `ats ignored` -- Adds and returns a Microsoft Foundry Deployment resource (e.g. an AI model) to the application model.
- [AddDeployment(IResourceBuilder<FoundryResource>, string, FoundryModel)](/reference/api/csharp/aspire.hosting.foundry/foundryextensions/methods.md#adddeployment-iresourcebuilder-foundryresource-string-foundrymodel) : `IResourceBuilder<FoundryDeploymentResource>` `extension` `ats ignored` -- Adds and returns a Microsoft Foundry Deployment resource to the application model using a [FoundryModel](/reference/api/csharp/aspire.hosting.foundry/foundrymodel.md).
- [AddFoundry(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.foundry/foundryextensions/methods.md#addfoundry-idistributedapplicationbuilder-string) : `IResourceBuilder<FoundryResource>` `extension` `ats export` -- Adds a Microsoft Foundry resource to the application model.
- [RunAsFoundryLocal(IResourceBuilder<FoundryResource>)](/reference/api/csharp/aspire.hosting.foundry/foundryextensions/methods.md#runasfoundrylocal-iresourcebuilder-foundryresource) : `IResourceBuilder<FoundryResource>` `extension` `ats export` -- Adds a Foundry Local resource to the distributed application builder.
- [WithProperties(IResourceBuilder<FoundryDeploymentResource>, Action<FoundryDeploymentResource>)](/reference/api/csharp/aspire.hosting.foundry/foundryextensions/methods.md#withproperties-iresourcebuilder-foundrydeploymentresource-action-foundrydeploymentresource) : `IResourceBuilder<FoundryDeploymentResource>` `extension` `ats export` -- Allows setting the properties of a Microsoft Foundry Deployment resource.
- [WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<FoundryResource>, CognitiveServicesBuiltInRole[])](/reference/api/csharp/aspire.hosting.foundry/foundryextensions/methods.md#withroleassignments-iresourcebuilder-t-iresourcebuilder-foundryresource-cognitiveservicesbuiltinrole) : `IResourceBuilder<T>` `extension` `ats ignored` -- Assigns the specified roles to the given resource, granting it the necessary permissions on the target Microsoft Foundry resource. This replaces the default role assignments for the resource.
