ElasticsearchBuilderExtensions.WithDataVolume Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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();