# YarpResourceExtensions

- Kind: `class`
- Package: [Aspire.Hosting.Yarp](/reference/api/csharp/aspire.hosting.yarp.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/YarpResourceExtensions.cs)

Provides extension methods for adding YARP resources to the application model.

## Definition

```csharp
namespace Aspire.Hosting;

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

## Methods

- [AddYarp(IDistributedApplicationBuilder, string)](/reference/api/csharp/aspire.hosting.yarp/yarpresourceextensions/methods.md#addyarp-idistributedapplicationbuilder-string) : `IResourceBuilder<YarpResource>` `extension` `ats export` -- Adds a YARP container to the application model.
- [PublishWithStaticFiles(IResourceBuilder<YarpResource>, IResourceBuilder<IResourceWithContainerFiles>)](/reference/api/csharp/aspire.hosting.yarp/yarpresourceextensions/methods.md#publishwithstaticfiles-iresourcebuilder-yarpresource-iresourcebuilder-iresourcewithcontainerfiles) : `IResourceBuilder<YarpResource>` `extension` `ats export` -- In publish mode, generates a Dockerfile that copies static files from the specified resource into /app/wwwroot.
- [WithConfiguration(IResourceBuilder<YarpResource>, Action<IYarpConfigurationBuilder>)](/reference/api/csharp/aspire.hosting.yarp/yarpresourceextensions/methods.md#withconfiguration-iresourcebuilder-yarpresource-action-iyarpconfigurationbuilder) : `IResourceBuilder<YarpResource>` `extension` `ats export` -- Configure the YARP resource.
- [WithHostHttpsPort(IResourceBuilder<YarpResource>, int?)](/reference/api/csharp/aspire.hosting.yarp/yarpresourceextensions/methods.md#withhosthttpsport-iresourcebuilder-yarpresource-int) : `IResourceBuilder<YarpResource>` `extension` `ats export` -- Configures the host HTTPS port that the YARP resource is exposed on instead of using randomly assigned port. This will only have effect if an HTTPS endpoint is configured on the YARP resource due to TLS termination being enabled.
- [WithHostPort(IResourceBuilder<YarpResource>, int?)](/reference/api/csharp/aspire.hosting.yarp/yarpresourceextensions/methods.md#withhostport-iresourcebuilder-yarpresource-int) : `IResourceBuilder<YarpResource>` `extension` `ats export` -- Configures the host port that the YARP resource is exposed on instead of using randomly assigned port.
- [WithStaticFiles(IResourceBuilder<YarpResource>)](/reference/api/csharp/aspire.hosting.yarp/yarpresourceextensions/methods.md#withstaticfiles-iresourcebuilder-yarpresource) : `IResourceBuilder<YarpResource>` `extension` `ats ignored` -- Enables static file serving in the YARP resource. Static files are served from the wwwroot folder.
- [WithStaticFiles(IResourceBuilder<YarpResource>, string)](/reference/api/csharp/aspire.hosting.yarp/yarpresourceextensions/methods.md#withstaticfiles-iresourcebuilder-yarpresource-string) : `IResourceBuilder<YarpResource>` `extension` `ats ignored` -- Enables static file serving. In run mode: bind mounts `sourcePath` to /wwwroot. In publish mode: generates a Dockerfile whose build context is `sourcePath` and copies its contents into /app/wwwroot baked into the image.
