Share via


AspireElasticClientsElasticsearchExtensions.AddElasticsearchClient Method

Definition

Registers Elastic.Clients.Elasticsearch.ElasticsearchClient instance for connecting to Elasticsearch with Elastic.Clients.Elasticsearch client.

public static void AddElasticsearchClient (this Microsoft.Extensions.Hosting.IHostApplicationBuilder builder, string connectionName, Action<Aspire.Elastic.Clients.Elasticsearch.ElasticClientsElasticsearchSettings>? configureSettings = default, Action<Elastic.Clients.Elasticsearch.ElasticsearchClientSettings>? configureClientSettings = default);
static member AddElasticsearchClient : Microsoft.Extensions.Hosting.IHostApplicationBuilder * string * Action<Aspire.Elastic.Clients.Elasticsearch.ElasticClientsElasticsearchSettings> * Action<Elastic.Clients.Elasticsearch.ElasticsearchClientSettings> -> unit
<Extension()>
Public Sub AddElasticsearchClient (builder As IHostApplicationBuilder, connectionName As String, Optional configureSettings As Action(Of ElasticClientsElasticsearchSettings) = Nothing, Optional configureClientSettings As Action(Of ElasticsearchClientSettings) = 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<ElasticClientsElasticsearchSettings>

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

configureClientSettings
Action<Elastic.Clients.Elasticsearch.ElasticsearchClientSettings>

An optional delegate that can be used for customizing ElasticsearchClientSettings.

Exceptions

If required ConnectionString is not provided in configuration section

Applies to