# RedPandaBuilderExtensions Methods

- Package: [CommunityToolkit.Aspire.Hosting.RedPanda](/reference/api/csharp/communitytoolkit.aspire.hosting.redpanda.md)
- Type: [RedPandaBuilderExtensions](/reference/api/csharp/communitytoolkit.aspire.hosting.redpanda/redpandabuilderextensions.md)
- Kind: `Methods`
- Members: `8`

Provides extension methods for adding Redpanda resources to an `Hosting.IDistributedApplicationBuilder`.

<a id="addredpanda"></a>
<a id="addredpanda-idistributedapplicationbuilder-string-int"></a>

## AddRedPanda(IDistributedApplicationBuilder, string, int?)

- Name: `AddRedPanda(IDistributedApplicationBuilder, string, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs#L35-L38)

Adds a Redpanda container resource to the application. Redpanda is a Kafka API compatible streaming platform, so the resource can be referenced by any Kafka client integration.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaServerResource> AddRedPanda(
        this IDistributedApplicationBuilder builder,
        string name,
        int? port = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource. This name is used as the connection string name when referenced in a dependency.
- `port` (`int?`) `optional`
  The host port that the Kafka API is exposed on. If `null` a random port is assigned.

## Returns

`IResourceBuilder<RedPandaServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This version of the package defaults to the tag of the container image.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="addredpanda-idistributedapplicationbuilder-string-action-redpandaserveroptions-int"></a>

## AddRedPanda(IDistributedApplicationBuilder, string, Action<RedPandaServerOptions>, int?)

- Name: `AddRedPanda(IDistributedApplicationBuilder, string, Action<RedPandaServerOptions>, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs#L61-L68)

Adds a Redpanda container resource to the application, using a delegate to configure broker options such as the CPU and memory limits. Redpanda is a Kafka API compatible streaming platform, so the resource can be referenced by any Kafka client integration.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaServerResource> AddRedPanda(
        this IDistributedApplicationBuilder builder,
        string name,
        Action<RedPandaServerOptions> configureOptions,
        int? port = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource. This name is used as the connection string name when referenced in a dependency.
- `configureOptions` (`Action<RedPandaServerOptions>`)
  A delegate that configures the [RedPandaServerOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.redpanda/redpandaserveroptions.md) for the broker.
- `port` (`int?`) `optional`
  The host port that the Kafka API is exposed on. If `null` a random port is assigned.

## Returns

`IResourceBuilder<RedPandaServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This version of the package defaults to the tag of the container image.

## ATS metadata

### Ignored by ATS

- Reason: Action<RedPandaServerOptions> is not ATS-compatible. Use the AddRedPanda(builder, name, port) overload instead.

<a id="withconsole"></a>
<a id="withconsole-iresourcebuilder-redpandaserverresource-action-iresourcebuilder-redpandaconsolecontainerresource-string"></a>

## WithConsole(IResourceBuilder<RedPandaServerResource>, Action<IResourceBuilder<RedPandaConsoleContainerResource>>, string?)

- Name: `WithConsole(IResourceBuilder<RedPandaServerResource>, Action<IResourceBuilder<RedPandaConsoleContainerResource>>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs#L197-L216)

Adds a Redpanda Console container to the application, configured to connect to the Redpanda broker.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaServerResource> WithConsole(
        this IResourceBuilder<RedPandaServerResource> builder,
        Action<IResourceBuilder<RedPandaConsoleContainerResource>>? configureContainer = null,
        string? containerName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RedPandaServerResource>`)
  The Redpanda server resource builder.
- `configureContainer` (`Action<IResourceBuilder<RedPandaConsoleContainerResource>>`) `optional`
  An optional callback to configure the Redpanda Console container resource.
- `containerName` (`string?`) `optional`
  The name of the container (optional).

## Returns

`IResourceBuilder<RedPandaServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1` for the Redpanda server resource.

## Remarks

This version of the package defaults to the tag of the container image.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
- Synchronous exports run on a background thread.

<a id="withdatabindmount"></a>
<a id="withdatabindmount-iresourcebuilder-redpandaserverresource-string-bool"></a>

## WithDataBindMount(IResourceBuilder<RedPandaServerResource>, string, bool)

- Name: `WithDataBindMount(IResourceBuilder<RedPandaServerResource>, string, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs#L175-L178)

Adds a bind mount for the data folder to a Redpanda container resource.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaServerResource> WithDataBindMount(
        this IResourceBuilder<RedPandaServerResource> builder,
        string source,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RedPandaServerResource>`)
  The resource builder.
- `source` (`string`)
  The source directory on the host to mount into the container.
- `isReadOnly` (`bool`) `optional`
  A flag that indicates if this is a read-only mount.

## Returns

`IResourceBuilder<RedPandaServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withdatavolume"></a>
<a id="withdatavolume-iresourcebuilder-redpandaserverresource-string-bool"></a>

## WithDataVolume(IResourceBuilder<RedPandaServerResource>, string?, bool)

- Name: `WithDataVolume(IResourceBuilder<RedPandaServerResource>, string?, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs#L157-L159)

Adds a named volume for the data folder to a Redpanda container resource.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaServerResource> WithDataVolume(
        this IResourceBuilder<RedPandaServerResource> builder,
        string? name = null,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RedPandaServerResource>`)
  The resource builder.
- `name` (`string?`) `optional`
  The name of the volume. Defaults to an auto-generated name based on the application and resource names.
- `isReadOnly` (`bool`) `optional`
  A flag that indicates if this is a read-only volume.

## Returns

`IResourceBuilder<RedPandaServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withhostport"></a>
<a id="withhostport-iresourcebuilder-redpandaconsolecontainerresource-int"></a>

## WithHostPort(IResourceBuilder<RedPandaConsoleContainerResource>, int?)

- Name: `WithHostPort(IResourceBuilder<RedPandaConsoleContainerResource>, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaConsoleContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs)

Configures the host port that the Redpanda Console resource is exposed on instead of using a randomly assigned port.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaConsoleContainerResource> WithHostPort(
        this IResourceBuilder<RedPandaConsoleContainerResource> builder,
        int? port)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RedPandaConsoleContainerResource>`)
  The resource builder for the Redpanda Console.
- `port` (`int?`)
  The port to bind on the host. If `null` a random port is assigned.

## Returns

`IResourceBuilder<RedPandaConsoleContainerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

<a id="withhostport-iresourcebuilder-redpandakafkauicontainerresource-int"></a>

## WithHostPort(IResourceBuilder<RedPandaKafkaUiContainerResource>, int?)

- Name: `WithHostPort(IResourceBuilder<RedPandaKafkaUiContainerResource>, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaKafkaUiContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs)

Configures the host port that the Kafka UI resource is exposed on instead of using a randomly assigned port.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaKafkaUiContainerResource> WithHostPort(
        this IResourceBuilder<RedPandaKafkaUiContainerResource> builder,
        int? port)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RedPandaKafkaUiContainerResource>`)
  The resource builder for the Kafka UI.
- `port` (`int?`)
  The port to bind on the host. If `null` a random port is assigned.

## Returns

`IResourceBuilder<RedPandaKafkaUiContainerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### Ignored by ATS

- Reason: The exported 'withHostPort' capability is already provided by the RedPandaConsoleContainerResource overload; this overload remains available to C# callers.

<a id="withkafkaui"></a>
<a id="withkafkaui-iresourcebuilder-redpandaserverresource-action-iresourcebuilder-redpandakafkauicontainerresource-string"></a>

## WithKafkaUI(IResourceBuilder<RedPandaServerResource>, Action<IResourceBuilder<RedPandaKafkaUiContainerResource>>, string?)

- Name: `WithKafkaUI(IResourceBuilder<RedPandaServerResource>, Action<IResourceBuilder<RedPandaKafkaUiContainerResource>>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<RedPandaServerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/4ff8268fbd97ddd23cb73dc8eff9cc92718156d1/src/CommunityToolkit.Aspire.Hosting.RedPanda/RedPandaBuilderExtensions.cs#L253-L272)

Adds a Kafka UI container to the application, configured to connect to the Redpanda broker. This is the same Kafka management UI (the `kafbat/kafka-ui` image) used by the official Aspire Kafka integration, so it works against any Kafka API compatible broker.

```csharp
public static class RedPandaBuilderExtensions
{
    public static IResourceBuilder<RedPandaServerResource> WithKafkaUI(
        this IResourceBuilder<RedPandaServerResource> builder,
        Action<IResourceBuilder<RedPandaKafkaUiContainerResource>>? configureContainer = null,
        string? containerName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<RedPandaServerResource>`)
  The Redpanda server resource builder.
- `configureContainer` (`Action<IResourceBuilder<RedPandaKafkaUiContainerResource>>`) `optional`
  An optional callback to configure the Kafka UI container resource.
- `containerName` (`string?`) `optional`
  The name of the container (optional).

## Returns

`IResourceBuilder<RedPandaServerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1` for the Redpanda server resource.

## Remarks

This version of the package defaults to the tag of the container image.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
- Synchronous exports run on a background thread.
