Share via


AspireWebPubSubExtensions.AddKeyedAzureWebPubSubServiceClient Method

Definition

Overloads

AddKeyedAzureWebPubSubServiceClient(IHostApplicationBuilder, String, Action<AzureMessagingWebPubSubSettings>, Action<IAzureClientBuilder<WebPubSubServiceClient, WebPubSubServiceClientOptions>>)

Registers WebPubSubServiceClient as a singleton for given connectionName in the services provided by the builder. This overload does not require a service key and uses the connection name as the service key to support scenarios where multiple Hubs are referenced in the same application.

AddKeyedAzureWebPubSubServiceClient(IHostApplicationBuilder, String, String, Action<AzureMessagingWebPubSubSettings>, Action<IAzureClientBuilder<WebPubSubServiceClient, WebPubSubServiceClientOptions>>)

Registers WebPubSubServiceClient as a singleton for given connectionName and serviceKey in the services provided by the builder.

AddKeyedAzureWebPubSubServiceClient(IHostApplicationBuilder, String, Action<AzureMessagingWebPubSubSettings>, Action<IAzureClientBuilder<WebPubSubServiceClient, WebPubSubServiceClientOptions>>)

Source:
AspireWebPubSubExtensions.cs

Registers WebPubSubServiceClient as a singleton for given connectionName in the services provided by the builder. This overload does not require a service key and uses the connection name as the service key to support scenarios where multiple Hubs are referenced in the same application.

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

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

connectionName
String

The name of the component to retrieve the connection string from the ConnectionStrings configuration section.

configureSettings
Action<AzureMessagingWebPubSubSettings>

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

configureClientBuilder
Action<IAzureClientBuilder<WebPubSubServiceClient,WebPubSubServiceClientOptions>>

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

Exceptions

Thrown when neither ConnectionString nor Endpoint is provided.

Remarks

Reads the configuration from "Aspire.Azure.Messaging.WebPubSub:{name}" section.

Applies to

AddKeyedAzureWebPubSubServiceClient(IHostApplicationBuilder, String, String, Action<AzureMessagingWebPubSubSettings>, Action<IAzureClientBuilder<WebPubSubServiceClient, WebPubSubServiceClientOptions>>)

Source:
AspireWebPubSubExtensions.cs
Source:
AspireWebPubSubExtensions.cs
Source:
AspireWebPubSubExtensions.cs
Source:
AspireWebPubSubExtensions.cs

Registers WebPubSubServiceClient as a singleton for given connectionName and serviceKey in the services provided by the builder.

public static void AddKeyedAzureWebPubSubServiceClient(this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, string serviceKey, Action<Aspire.Azure.Messaging.WebPubSub.AzureMessagingWebPubSubSettings>? configureSettings = default, Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Messaging.WebPubSub.WebPubSubServiceClient,Azure.Messaging.WebPubSub.WebPubSubServiceClientOptions>>? configureClientBuilder = default);
static member AddKeyedAzureWebPubSubServiceClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * string * Action<Aspire.Azure.Messaging.WebPubSub.AzureMessagingWebPubSubSettings> * Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Messaging.WebPubSub.WebPubSubServiceClient, Azure.Messaging.WebPubSub.WebPubSubServiceClientOptions>> -> unit
<Extension()>
Public Sub AddKeyedAzureWebPubSubServiceClient (builder As IHostApplicationBuilder, connectionName As String, serviceKey As String, Optional configureSettings As Action(Of AzureMessagingWebPubSubSettings) = Nothing, Optional configureClientBuilder As Action(Of IAzureClientBuilder(Of WebPubSubServiceClient, WebPubSubServiceClientOptions)) = Nothing)

Parameters

builder
IHostApplicationBuilder

The IHostApplicationBuilder to read config from and add services to.

connectionName
String

The name of the component to retrieve the connection string from the ConnectionStrings configuration section.

serviceKey
String

The name of the component, which is used as the ServiceKey of the service, as well as the hub name is hub name is not set in the settings

configureSettings
Action<AzureMessagingWebPubSubSettings>

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

configureClientBuilder
Action<IAzureClientBuilder<WebPubSubServiceClient,WebPubSubServiceClientOptions>>

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

Exceptions

Thrown when neither ConnectionString nor Endpoint is provided.

Remarks

Reads the configuration from "Aspire.Azure.Messaging.WebPubSub:{name}" section.

Applies to