# KafkaServerResource

- Module: [Aspire.Hosting.Kafka](/reference/api/typescript/aspire.hosting.kafka.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

A resource that represents a Kafka broker.

## Definition

```typescript
interface KafkaServerResource
  extends IComputeResource,
    IExpressionValue,
    IManifestExpressionProvider,
    IResource,
    IResourceWithArgs,
    IResourceWithConnectionString,
    IResourceWithEndpoints,
    IResourceWithEnvironment,
    IResourceWithProbes,
    IResourceWithWaitSupport,
    IValueProvider,
    IValueWithReferences {
  readonly connectionStringExpression: ReferenceExpression;
  readonly host: EndpointReferenceExpression;
  readonly internalEndpoint: EndpointReference;
  readonly port: EndpointReferenceExpression;
  readonly primaryEndpoint: EndpointReference;
  withDataBindMount(
      source: string,
      isReadOnly?: boolean): KafkaServerResource;
  withDataVolume(
      name?: string,
      isReadOnly?: boolean): KafkaServerResource;
  withKafkaUI(configureContainer?: (obj: KafkaUIContainerResource) => Promise<void>, containerName?: string): KafkaServerResource;
}
```

## Properties

- `connectionStringExpression`: `ReferenceExpression` `get` -- Gets the connection string expression for the Kafka broker.
- `host`: `EndpointReferenceExpression` `get` -- Gets the host endpoint reference for the primary endpoint.
- `internalEndpoint`: `EndpointReference` `get` -- Gets the internal endpoint for the Kafka broker. This endpoint is used for container to broker communication. To connect to the Kafka broker from a host process, use `PrimaryEndpoint`.
- `port`: `EndpointReferenceExpression` `get` -- Gets the port endpoint reference for the primary endpoint.
- `primaryEndpoint`: `EndpointReference` `get` -- Gets the primary endpoint for the Kafka broker. This endpoint is used for host processes to Kafka broker communication. To connect to the Kafka broker from a container, use `InternalEndpoint`.

## Methods

- [withDataBindMount](/reference/api/typescript/aspire.hosting.kafka/kafkaserverresource/withdatabindmount.md) -- `method` -- Adds a bind mount for the data folder to a Kafka container resource.
    ```typescript
  withDataBindMount(source: string, isReadOnly?: boolean): KafkaServerResource
  ```
- [withDataVolume](/reference/api/typescript/aspire.hosting.kafka/kafkaserverresource/withdatavolume.md) -- `method` -- Adds a named volume for the data folder to a Kafka container resource.
    ```typescript
  withDataVolume(name?: string, isReadOnly?: boolean): KafkaServerResource
  ```
- [withKafkaUI](/reference/api/typescript/aspire.hosting.kafka/kafkaserverresource/withkafkaui.md) -- `method` -- Adds a Kafka UI container to the application.
    ```typescript
  withKafkaUI(configureContainer?: (obj: KafkaUIContainerResource) => Promise<void>, containerName?: string): KafkaServerResource
  ```
