Share via


AspireAzureSearchExtensions.AddKeyedAzureSearchClient Method

Definition

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

public static void AddKeyedAzureSearchClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string name, Action<Aspire.Azure.Search.Documents.AzureSearchSettings>? configureSettings = default, Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Search.Documents.Indexes.SearchIndexClient,Azure.Search.Documents.SearchClientOptions>>? configureClientBuilder = default);
static member AddKeyedAzureSearchClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Azure.Search.Documents.AzureSearchSettings> * Action<Azure.Core.Extensions.IAzureClientBuilder<Azure.Search.Documents.Indexes.SearchIndexClient, Azure.Search.Documents.SearchClientOptions>> -> unit
<Extension()>
Public Sub AddKeyedAzureSearchClient (builder As IHostApplicationBuilder, name As String, Optional configureSettings As Action(Of AzureSearchSettings) = Nothing, Optional configureClientBuilder As Action(Of IAzureClientBuilder(Of SearchIndexClient, SearchClientOptions)) = 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<AzureSearchSettings>

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

configureClientBuilder
Action<IAzureClientBuilder<SearchIndexClient,SearchClientOptions>>

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

Remarks

Reads the configuration from "Aspire:Azure:Search:Documents:{name}" section.

Applies to