AspireServiceBusExtensions.AddAzureServiceBusClient Method

Definition

Registers ServiceBusClient as a singleton in the services provided by the builder.

public static void AddAzureServiceBusClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Aspire.Azure.Messaging.ServiceBus.AzureMessagingServiceBusSettings>? configureSettings = default, Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Messaging.ServiceBus.ServiceBusClient,Azure.Messaging.ServiceBus.ServiceBusClientOptions>>? configureClientBuilder = default);
static member AddAzureServiceBusClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Azure.Messaging.ServiceBus.AzureMessagingServiceBusSettings> * Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Messaging.ServiceBus.ServiceBusClient, Azure.Messaging.ServiceBus.ServiceBusClientOptions>> -> unit
<Extension()>
Public Sub AddAzureServiceBusClient (builder As IHostApplicationBuilder, connectionName As String, Optional configureSettings As Action(Of AzureMessagingServiceBusSettings) = Nothing, Optional configureClientBuilder As Action(Of IAzureClientBuilder(Of ServiceBusClient, ServiceBusClientOptions)) = Nothing)

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

connectionName
String

A name used to retrieve the connection string from the ConnectionStrings configuration section.

configureSettings
Action<AzureMessagingServiceBusSettings>

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

configureClientBuilder
Action<IAzureClientBuilder<ServiceBusClient,ServiceBusClientOptions>>

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

Exceptions

Remarks

Reads the configuration from "Aspire:Azure:Messaging:ServiceBus" section.

Applies to