Elasticsearch extensions integration
Цей контент ще не доступний вашою мовою.
This add-on extends the official Aspire Elasticsearch hosting resource with Elasticvue, a browser-based Elasticsearch administration interface. It is not a separate Elasticsearch server integration.
Prerequisites
Section titled “Prerequisites”- Add the official 📦 Aspire.Hosting.Elasticsearch package to the AppHost.
- Use Docker to run the Elasticsearch and Elasticvue containers.
Install the extension
Section titled “Install the extension”Install the Community Toolkit extension in the AppHost:
aspire add communitytoolkit-elasticsearch-extensionsAspire CLI інтерактивний; оберіть відповідний результат пошуку:
Select an integration to add:
> communitytoolkit-elasticsearch-extensions (CommunityToolkit.Aspire.Hosting.Elasticsearch.Extensions)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.Elasticsearch.Extensions@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.Elasticsearch.Extensions" Version="*" />Add Elasticvue to an Elasticsearch resource
Section titled “Add Elasticvue to an Elasticsearch resource”Call WithElasticvue on the official Elasticsearch resource. Elasticvue waits for Elasticsearch to become ready. The extension also enables Elasticsearch CORS for the Elasticvue endpoint and configures Elasticvue to connect using the resource’s elastic credentials.
var builder = DistributedApplication.CreateBuilder(args);
var elasticsearch = builder.AddElasticsearch("elasticsearch") .WithElasticvue();
builder.AddProject<Projects.Api>("api") .WithReference(elasticsearch);
// After adding all resources, run the app...builder.Build().Run();The extension reads the Elasticsearch resource’s generated password when it configures Elasticvue. Keep the official resource name, such as elasticsearch, consistent with the name used by dependent projects.
Multiple calls to WithElasticvue reuse one Elasticvue container and add the Elasticsearch clusters to its configuration. The Elasticvue container is excluded from the deployment manifest and has no dedicated health check; its readiness dependency is the Elasticsearch resource.
Configure the Elasticvue container
Section titled “Configure the Elasticvue container”The optional configureContainer callback lets you configure the Elasticvue container builder. Use its exported WithHostPort method to choose a stable local port instead of Aspire assigning one:
var builder = DistributedApplication.CreateBuilder(args);
var elasticsearch = builder.AddElasticsearch("elasticsearch") .WithElasticvue(configureContainer: elasticvue => elasticvue.WithHostPort(8080));
// After adding all resources, run the app...builder.Build().Run();containerName optionally changes the Elasticvue resource name. It defaults to elasticvue. The host port is optional; omit it to let Aspire assign a port.
Elasticvue listens on container port 8080; WithHostPort selects the corresponding fixed host port.
Exported AppHost API
Section titled “Exported AppHost API”The extension package exports these APIs:
WithElasticvue(configureContainer, containerName)adds and configures the Elasticvue container for an officialElasticsearchResource.WithHostPort(port)sets the host port on the Elasticvue resource builder. Call it fromconfigureContainer; the extension does not expose a public method to add Elasticvue independently.