共用方式為


ElasticsearchBuilderExtensions.WithDataVolume Method

Definition

Adds a named volume for the data folder to a Elasticsearch container resource.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource> WithDataVolume (this Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource> builder, string? name = default);
static member WithDataVolume : Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource> * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ElasticsearchResource>
<Extension()>
Public Function WithDataVolume (builder As IResourceBuilder(Of ElasticsearchResource), Optional name As String = Nothing) As IResourceBuilder(Of ElasticsearchResource)

Parameters

builder
IResourceBuilder<ElasticsearchResource>

The resource builder.

name
String

The name of the volume. Defaults to an auto-generated name based on the application and resource names.

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 data volume is added to the container to allow data to be persisted across container restarts.

var builder = DistributedApplication.CreateBuilder(args);

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

builder.Build().Run();

Applies to