# IYarpConfigurationBuilder Methods

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

Interface to build a configuration file for YARP

## AddCluster(EndpointReference)

- Name: `AddCluster(EndpointReference)`
- Modifiers: `abstract`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/IYarpConfigurationBuilder.cs#L73)

Add a new cluster to YARP.

```csharp
public interface IYarpConfigurationBuilder
{
    public abstract YarpCluster AddCluster(
        EndpointReference endpoint)
    {
        // ...
    }
}
```

## Parameters

- `endpoint` (`EndpointReference`)
  The endpoint target for this cluster.

## Returns

[YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md) -- The created cluster for further configuration.

## Remarks

This overload is not available in polyglot app hosts. Use the `addClusterFromEndpoint` helper instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddCluster(IResourceBuilder<IResourceWithServiceDiscovery>)

- Name: `AddCluster(IResourceBuilder<IResourceWithServiceDiscovery>)`
- Modifiers: `abstract`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/IYarpConfigurationBuilder.cs#L73)

Add a new cluster to YARP based on a resource that supports service discovery.

```csharp
public interface IYarpConfigurationBuilder
{
    public abstract YarpCluster AddCluster(
        IResourceBuilder<IResourceWithServiceDiscovery> resource)
    {
        // ...
    }
}
```

## Parameters

- `resource` (`IResourceBuilder<IResourceWithServiceDiscovery>`)
  The resource target for this cluster.

## Returns

[YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md) -- The created cluster for further configuration.

## Remarks

This overload is not available in polyglot app hosts. Use the `addClusterFromResource` helper instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddCluster(IResourceBuilder<ExternalServiceResource>)

- Name: `AddCluster(IResourceBuilder<ExternalServiceResource>)`
- Modifiers: `abstract`
- Returns: [YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Yarp/ConfigurationBuilder/IYarpConfigurationBuilder.cs#L73)

Add a new cluster to YARP based on an external service resource.

```csharp
public interface IYarpConfigurationBuilder
{
    public abstract YarpCluster AddCluster(
        IResourceBuilder<ExternalServiceResource> externalService)
    {
        // ...
    }
}
```

## Parameters

- `externalService` (`IResourceBuilder<ExternalServiceResource>`)
  The external service used by this cluster.

## Returns

[YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md) -- The created cluster for further configuration.

## Remarks

This overload is not available in polyglot app hosts. Use the `addClusterFromExternalService` helper instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddCluster(string, object[])

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

Add a new cluster to YARP based on a collection of urls.

```csharp
public interface IYarpConfigurationBuilder
{
    public abstract YarpCluster AddCluster(
        string clusterName,
        object[] destinations)
    {
        // ...
    }
}
```

## Parameters

- `clusterName` (`string`)
  The name of the cluster.
- `destinations` (`object[]`)
  The destinations used by this cluster.

## Returns

[YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md) -- The created cluster for further configuration.

## Remarks

This overload is not available in polyglot app hosts. Use the `addClusterWithDestinations` helper instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddCluster(string, object)

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

Add a new cluster to YARP based on a collection of urls.

```csharp
public interface IYarpConfigurationBuilder
{
    public virtual YarpCluster AddCluster(
        string clusterName,
        object destination)
    {
        // ...
    }
}
```

## Parameters

- `clusterName` (`string`)
  The name of the cluster.
- `destination` (`object`)
  The destinations used by this cluster.

## Returns

[YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md) -- The created cluster for further configuration.

## Remarks

This overload is not available in polyglot app hosts. Use the `addClusterWithDestination` helper instead.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## AddRoute(string, YarpCluster)

- Name: `AddRoute(string, YarpCluster)`
- Modifiers: `abstract`
- Returns: [YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md)

Add a new route to YARP that will target the cluster in parameter.

```csharp
public interface IYarpConfigurationBuilder
{
    public abstract YarpRoute AddRoute(
        string path,
        YarpCluster cluster)
    {
        // ...
    }
}
```

## Parameters

- `path` (`string`)
  The path to match for this route.
- `cluster` ([YarpCluster](/reference/api/csharp/aspire.hosting.yarp/yarpcluster.md))
  The target cluster for this route.

## Returns

[YarpRoute](/reference/api/csharp/aspire.hosting.yarp/yarproute.md) -- The created route for further configuration.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
