Share via


AspireEventHubsExtensions.AddKeyedAzureEventHubConsumerClient Method

Definition

Registers EventHubConsumerClient as a singleton for given name in the services provided by the builder.

public static void AddKeyedAzureEventHubConsumerClient(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string name, Action<Aspire.Azure.Messaging.EventHubs.AzureMessagingEventHubsConsumerSettings>? configureSettings = default, Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Messaging.EventHubs.Consumer.EventHubConsumerClient,Azure.Messaging.EventHubs.Consumer.EventHubConsumerClientOptions>>? configureClientBuilder = default);
static member AddKeyedAzureEventHubConsumerClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Azure.Messaging.EventHubs.AzureMessagingEventHubsConsumerSettings> * Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Messaging.EventHubs.Consumer.EventHubConsumerClient, Azure.Messaging.EventHubs.Consumer.EventHubConsumerClientOptions>> -> unit
<Extension()>
Public Sub AddKeyedAzureEventHubConsumerClient (builder As IHostApplicationBuilder, name As String, Optional configureSettings As Action(Of AzureMessagingEventHubsConsumerSettings) = Nothing, Optional configureClientBuilder As Action(Of IAzureClientBuilder(Of EventHubConsumerClient, EventHubConsumerClientOptions)) = Nothing)

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

name
String

The name of the component, which is used as the ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section.

configureSettings
Action<AzureMessagingEventHubsConsumerSettings>

An optional method that can be used for customizing the AzureMessagingEventHubsConsumerSettings. It's invoked after the settings are read from the configuration.

configureClientBuilder
Action<IAzureClientBuilder<EventHubConsumerClient,EventHubConsumerClientOptions>>

An optional method that can be used for customizing the IAzureClientBuilder<TClient,TOptions>.

Exceptions

Thrown when the name argument is null or empty.

Remarks

Reads the configuration from "Aspire:Azure:Messaging:EventHubs:{TClient}" section, where {TClient} is the type of Event Hubs client being configured, i.e. EventProcessorClient.

Applies to