Get started with the SeaweedFS integration
SeaweedFS is a distributed storage system with native Master, Volume, and Filer APIs and an optional S3-compatible gateway. The Community Toolkit provides an AppHost integration and a .NET client package for its S3 and Filer APIs.
Why use SeaweedFS with Aspire
Section titled “Why use SeaweedFS with Aspire”- Enable only the APIs your application uses.
- Reference a SeaweedFS resource to pass dynamically assigned endpoints and S3 credentials to dependent projects.
- Persist cluster files in a Docker volume or a host bind mount.
- Register typed .NET clients with configuration and health checks.
Prerequisites
Section titled “Prerequisites”- The Aspire CLI and the other Aspire prerequisites.
- Docker to run the SeaweedFS container.
- .NET 10 or later for the Community Toolkit client package.
How the integration fits together
Section titled “How the integration fits together”The hosting package starts a SeaweedFS container with the Master and Volume services. Add WithFiler for the native Filer API, or WithS3 for the S3-compatible gateway. The S3 gateway also enables the Filer API because it depends on it. The client package reads endpoint and credential values from Aspire configuration and registers the matching .NET client.
Start using SeaweedFS
Section titled “Start using SeaweedFS”-
Install the hosting package in the AppHost.
Aspire CLI — Add CommunityToolkit.Aspire.Hosting.SeaweedFS package aspire add seaweedfsThe Aspire CLI is interactive, be sure to select the appropriate search result when prompted:
Aspire CLI — Example output prompt Select an integration to add:> seaweedfs (CommunityToolkit.Aspire.Hosting.SeaweedFS)> Other results listed as selectable options...C# — AppHost.cs #:package CommunityToolkit.Aspire.Hosting.SeaweedFS@*XML — Add CommunityToolkit.Aspire.Hosting.SeaweedFS package reference <PackageReference Include="CommunityToolkit.Aspire.Hosting.SeaweedFS" Version="*" /> -
Add the resource and opt in to either the native Filer API, the S3 gateway, or both. See Host SeaweedFS in the AppHost for endpoint, security, and persistence options.
-
Install the client package in a .NET project and register the client for the same resource name used in the AppHost. See Connect to SeaweedFS for S3 and Filer client examples.
Minimal AppHost flow
Section titled “Minimal AppHost flow”The S3 gateway uses target port 8333 by default and enables the Filer API at target port 8888. Aspire assigns host ports unless you configure them:
import { function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder } from './.aspire/modules/aspire.mjs';
const const builder: IDistributedApplicationBuilder
builder = await function createBuilder(): IDistributedApplicationBuilder
Creates a new distributed application builder
createBuilder();
const const seaweedfs: SeaweedFSContainerResource
seaweedfs = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addSeaweedFS(name: string): SeaweedFSContainerResource
Adds a base SeaweedFS container (Master and Volume APIs) to the application model. Chain with .WithS3() or .WithFiler() to enable additional APIs.
addSeaweedFS('seaweedfs');await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withS3(options?: { s3Port?: number;}): SeaweedFSContainerResource (+1 overload)
Enables the SeaweedFS S3-Compatible API Gateway.
withS3();await const seaweedfs: SeaweedFSContainerResource
seaweedfs.SeaweedFSContainerResource.withDataVolume(options?: { name?: string; isReadOnly?: boolean;}): SeaweedFSContainerResource (+1 overload)
Adds a named volume for the SeaweedFS data folder.
withDataVolume();
const const api: DotnetProjectResource
api = await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.addDotnetProject(name: string, path: string, options?: DotnetProjectOptions): DotnetProjectResource
Adds a .NET application resource.
addDotnetProject('api', '../Api/Api.csproj');await const api: DotnetProjectResource
api.ExecutableResource.withReference(source: IResource | EndpointReference | string | uri, options?: { connectionName?: string; optional?: boolean; name?: string;} | undefined): DotnetProjectResource (+1 overload)
Adds a reference to another resource
withReference(const seaweedfs: SeaweedFSContainerResource
seaweedfs);
await const builder: IDistributedApplicationBuilder
builder.IDistributedApplicationBuilder.build(): DistributedApplication
Builds the distributed application
build().DistributedApplication.run(cancellationToken?: cancellationToken): void
Runs the distributed application
run();var builder = DistributedApplication.CreateBuilder(args);
var seaweedfs = builder.AddSeaweedFS("seaweedfs") .WithS3() .WithDataVolume();
builder.AddDotnetProject("api", "../Api/Api.csproj") .WithReference(seaweedfs);
// After adding all resources, run the app...builder.Build().Run();