Freigeben über


ElasticsearchBuilderExtensions.WithDataBindMount Method

Definition

Adds a bind mount for the data folder to a Elasticsearch container resource.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource> WithDataBindMount (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource> builder, string source);
static member WithDataBindMount : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource> * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource>
<Extension()>
Public Function WithDataBindMount (builder As IResourceBuilder(Of ElasticsearchResource), source As String) As IResourceBuilder(Of ElasticsearchResource)

Parameters

builder
IResourceBuilder<ElasticsearchResource>

The resource builder.

source
String

The source directory on the host to mount into the container.

Returns

The IResourceBuilder<T>.

Examples

Add an Elasticsearch container to the application model and reference it in a .NET project. Additionally, in this example a bind mount is added to the container to allow data to be persisted across container restarts.

var builder = DistributedApplication.CreateBuilder(args);

var elasticsearch = builder.AddElasticsearch("elasticsearch")
.WithDataBindMount("./data/elasticsearch/data");
var api = builder.AddProject<Projects.Api>("api")
  .WithReference(elasticsearch);

builder.Build().Run();

Applies to