Skip to content
DocsTry Aspire
DocsTry

KafkaBuilderExtensions Methods

ClassMethods5 members
Provides extension methods for adding Kafka resources to the application model.
AddKafka(IDistributedApplicationBuilder, string, int?)Section titled AddKafka(IDistributedApplicationBuilder, string, int?)extensionIResourceBuilder<KafkaServerResource>
Adds a Kafka resource to the application. A container is used for local development.
public static class KafkaBuilderExtensions
{
public static IResourceBuilder<KafkaServerResource> AddKafka(
this IDistributedApplicationBuilder builder,
string name,
int? port = null)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder.
namestringThe name of the resource. This name will be used as the connection string name when referenced in a dependency
portint?optionalThe host port of Kafka broker.
IResourceBuilder<KafkaServerResource>A reference to the ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the container image.
WithDataBindMount(IResourceBuilder<KafkaServerResource>, string, bool)Section titled WithDataBindMount(IResourceBuilder<KafkaServerResource>, string, bool)extensionIResourceBuilder<KafkaServerResource>
Adds a bind mount for the data folder to a Kafka container resource.
public static class KafkaBuilderExtensions
{
public static IResourceBuilder<KafkaServerResource> WithDataBindMount(
this IResourceBuilder<KafkaServerResource> builder,
string source,
bool isReadOnly = false)
{
// ...
}
}
builderIResourceBuilder<KafkaServerResource>The resource builder.
sourcestringThe source directory on the host to mount into the container.
isReadOnlybooloptionalA flag that indicates if this is a read-only mount.
IResourceBuilder<KafkaServerResource>The ApplicationModel.IResourceBuilder`1.
WithDataVolume(IResourceBuilder<KafkaServerResource>, string?, bool)Section titled WithDataVolume(IResourceBuilder<KafkaServerResource>, string?, bool)extensionIResourceBuilder<KafkaServerResource>
Adds a named volume for the data folder to a Kafka container resource.
public static class KafkaBuilderExtensions
{
public static IResourceBuilder<KafkaServerResource> WithDataVolume(
this IResourceBuilder<KafkaServerResource> builder,
string? name = null,
bool isReadOnly = false)
{
// ...
}
}
builderIResourceBuilder<KafkaServerResource>The resource builder.
namestring?optionalThe name of the volume. Defaults to an auto-generated name based on the application and resource names.
isReadOnlybooloptionalA flag that indicates if this is a read-only volume.
IResourceBuilder<KafkaServerResource>The ApplicationModel.IResourceBuilder`1.
WithHostPort(IResourceBuilder<KafkaUIContainerResource>, int?)Section titled WithHostPort(IResourceBuilder<KafkaUIContainerResource>, int?)extensionIResourceBuilder<KafkaUIContainerResource>
Configures the host port that the KafkaUI resource is exposed on instead of using randomly assigned port.
public static class KafkaBuilderExtensions
{
public static IResourceBuilder<KafkaUIContainerResource> WithHostPort(
this IResourceBuilder<KafkaUIContainerResource> builder,
int? port)
{
// ...
}
}
builderIResourceBuilder<KafkaUIContainerResource>The resource builder for KafkaUI.
portint?The port to bind on the host. If null is used random port will be assigned.
IResourceBuilder<KafkaUIContainerResource>The resource builder for KafkaUI.
WithKafkaUI(IResourceBuilder<KafkaServerResource>, Action<IResourceBuilder<KafkaUIContainerResource>>, string?)Section titled WithKafkaUI(IResourceBuilder<KafkaServerResource>, Action<IResourceBuilder<KafkaUIContainerResource>>, string?)extensionIResourceBuilder<KafkaServerResource>
Adds a Kafka UI container to the application.
public static class KafkaBuilderExtensions
{
public static IResourceBuilder<KafkaServerResource> WithKafkaUI(
this IResourceBuilder<KafkaServerResource> builder,
Action<IResourceBuilder<KafkaUIContainerResource>>? configureContainer = null,
string? containerName = null)
{
// ...
}
}
builderIResourceBuilder<KafkaServerResource>The Kafka server resource builder.
configureContainerAction<IResourceBuilder<KafkaUIContainerResource>>optionalConfiguration callback for KafkaUI container resource.
containerNamestring?optionalThe name of the container (Optional).
IResourceBuilder<KafkaServerResource>A reference to the ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the container image.