# YarpClusterExtensions Methods

- Package: [Aspire.Hosting.Yarp](/reference/api/csharp/aspire.hosting.yarp.md)
- Type: [YarpClusterExtensions](/reference/api/csharp/aspire.hosting.yarp/yarpclusterextensions.md)
- Kind: `Methods`
- Members: `6`

Provides extension methods for configuring a YARP cluster.

## WithForwarderRequestConfig(YarpCluster, ForwarderRequestConfig)

- Name: `WithForwarderRequestConfig(YarpCluster, ForwarderRequestConfig)`
- Modifiers: `extension`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs)

Set the ForwarderRequestConfig for the cluster.

```csharp
public static class YarpClusterExtensions
{
    public static YarpCluster WithForwarderRequestConfig(
        this YarpCluster cluster,
        ForwarderRequestConfig config)
    {
        // ...
    }
}
```

## Parameters

- `cluster` ([YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md))
- `config` (`ForwarderRequestConfig`)

## Remarks

This overload is not available in polyglot app hosts. Use the DTO-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithHealthCheckConfig(YarpCluster, HealthCheckConfig)

- Name: `WithHealthCheckConfig(YarpCluster, HealthCheckConfig)`
- Modifiers: `extension`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs)

Set the HealthCheckConfig for the cluster.

```csharp
public static class YarpClusterExtensions
{
    public static YarpCluster WithHealthCheckConfig(
        this YarpCluster cluster,
        HealthCheckConfig config)
    {
        // ...
    }
}
```

## Parameters

- `cluster` ([YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md))
- `config` (`HealthCheckConfig`)

## Remarks

This overload is not available in polyglot app hosts. Use the DTO-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithHttpClientConfig(YarpCluster, HttpClientConfig)

- Name: `WithHttpClientConfig(YarpCluster, HttpClientConfig)`
- Modifiers: `extension`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs)

Set the ForwarderRequestConfig for the cluster.

```csharp
public static class YarpClusterExtensions
{
    public static YarpCluster WithHttpClientConfig(
        this YarpCluster cluster,
        HttpClientConfig config)
    {
        // ...
    }
}
```

## Parameters

- `cluster` ([YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md))
- `config` (`HttpClientConfig`)

## Remarks

This overload is not available in polyglot app hosts. Use the DTO-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithLoadBalancingPolicy(YarpCluster, string)

- Name: `WithLoadBalancingPolicy(YarpCluster, string)`
- Modifiers: `extension`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs#L277-L278)

Set the LoadBalancingPolicy for the cluster.

```csharp
public static class YarpClusterExtensions
{
    public static YarpCluster WithLoadBalancingPolicy(
        this YarpCluster cluster,
        string policy)
    {
        // ...
    }
}
```

## Parameters

- `cluster` ([YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md))
- `policy` (`string`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithMetadata(YarpCluster, IReadOnlyDictionary<string, string>)

- Name: `WithMetadata(YarpCluster, IReadOnlyDictionary<string, string>)`
- Modifiers: `extension`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs#L287-L288)

Set the Metadata for the cluster.

```csharp
public static class YarpClusterExtensions
{
    public static YarpCluster WithMetadata(
        this YarpCluster cluster,
        IReadOnlyDictionary<string, string> metadata)
    {
        // ...
    }
}
```

## Parameters

- `cluster` ([YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md))
- `metadata` (`IReadOnlyDictionary<string, string>`)

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithSessionAffinityConfig(YarpCluster, SessionAffinityConfig)

- Name: `WithSessionAffinityConfig(YarpCluster, SessionAffinityConfig)`
- Modifiers: `extension`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs)

Set the SessionAffinityConfig for the cluster.

```csharp
public static class YarpClusterExtensions
{
    public static YarpCluster WithSessionAffinityConfig(
        this YarpCluster cluster,
        SessionAffinityConfig config)
    {
        // ...
    }
}
```

## Parameters

- `cluster` ([YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md))
- `config` (`SessionAffinityConfig`)

## Remarks

This overload is not available in polyglot app hosts. Use the DTO-based overload instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
