SeaweedFS integration in the AppHost

यह कंटेंट अभी तक आपकी भाषा में उपलब्ध नहीं है।

⭐ Community Toolkit

The SeaweedFS hosting package runs the SeaweedFS container and exposes its APIs when enabled. For an overview, see Get started with the SeaweedFS integration.

Install the package in the AppHost:

Aspire CLI — CommunityToolkit.Aspire.Hosting.SeaweedFS पैकेज जोड़ें
aspire add seaweedfs

Aspire CLI इंटरैक्टिव है; प्रॉम्प्ट पर उपयुक्त परिणाम चुनें:

Aspire CLI — उदाहरण आउटपुट
Select an integration to add:
> seaweedfs (CommunityToolkit.Aspire.Hosting.SeaweedFS)
> Other results listed as selectable options...

AddSeaweedFS starts the Master and Volume APIs. Call WithFiler to enable the native Filer API. Call WithS3 to enable the S3 gateway; this also enables Filer because the gateway depends on it.

apphost.mts
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
();
const
const api: ProjectResource
api
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addProject(name: string, projectPath: string, options?: {
launchProfileOrOptions?: string | ProjectResourceOptions;
}): ProjectResource (+1 overload)

Adds a .NET project resource

addProject
('api', '../Api/Api.csproj');
await
const api: ProjectResource
api
.
ProjectResource.withReference(source: IResource | EndpointReference | string | uri, options?: {
connectionName?: string;
optional?: boolean;
name?: string;
} | undefined): ProjectResource (+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
();

The resource starts with Master port 9333 and Volume port 8080. WithFiler adds Filer port 8888; WithS3 adds S3 port 8333. Aspire assigns host ports automatically unless a method receives a fixed port.

Use the native Filer endpoint without starting S3. The example also sets a host port for the Master API and Filer API:

apphost.mts
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.withFiler(filerPort?: number): SeaweedFSContainerResource (+1 overload)

Enables the SeaweedFS Native Filer API.

withFiler
(8888);
await
const seaweedfs: SeaweedFSContainerResource
seaweedfs
.
SeaweedFSContainerResource.withHostPort(port: number | null): SeaweedFSContainerResource

Configures the Master API host port that the SeaweedFS resource is exposed on.

withHostPort
(9333);
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

WithHostPort sets the host port for the Master API. The optional port parameters on WithFiler and WithS3 set the host ports for those endpoints.

AddSeaweedFS creates an admin access-key parameter and a generated secret-key parameter. Provide your own parameters when the S3 identity should use other credentials:

apphost.mts
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 accessKey: ParameterResource
accessKey
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
('seaweedfs-access-key', {
secret?: boolean | undefined
secret
: true,
});
const
const secretKey: ParameterResource
secretKey
= await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.addParameter(name: string, options?: {
value?: string;
publishValueAsDefault?: boolean;
secret?: boolean;
}): ParameterResource (+1 overload)

Adds a parameter resource

addParameter
('seaweedfs-secret-key', {
secret?: boolean | undefined
secret
: true,
});
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.withAccessKey(accessKey: string | ParameterResource): SeaweedFSContainerResource

Configures the Access Key that the SeaweedFS S3 resource uses.

withAccessKey
(
const accessKey: ParameterResource
accessKey
);
await
const seaweedfs: SeaweedFSContainerResource
seaweedfs
.
SeaweedFSContainerResource.withSecretKey(secretKey: string | ParameterResource): SeaweedFSContainerResource

Configures the Secret Key that the SeaweedFS S3 resource uses.

withSecretKey
(
const secretKey: ParameterResource
secretKey
);
await
const seaweedfs: SeaweedFSContainerResource
seaweedfs
.
SeaweedFSContainerResource.withS3(options?: {
s3Port?: number;
}): SeaweedFSContainerResource (+1 overload)

Enables the SeaweedFS S3-Compatible API Gateway.

withS3
();
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

The integration writes the selected credentials into the S3 identity configuration it generates for the container. Store secrets in a secret provider rather than source control.

Use WithDataVolume to persist /data outside the container lifecycle. Aspire generates a volume name unless you provide one:

apphost.mts
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(name?: string, isReadOnly?: boolean): SeaweedFSContainerResource (+1 overload)

Adds a named volume for the SeaweedFS data folder.

withDataVolume
('seaweedfs-data');
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

Use WithDataBindMount to access a specific host directory directly:

apphost.mts
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.withFiler(options?: {
filerPort?: number;
}): SeaweedFSContainerResource (+1 overload)

Enables the SeaweedFS Native Filer API.

withFiler
();
await
const seaweedfs: SeaweedFSContainerResource
seaweedfs
.
SeaweedFSContainerResource.withDataBindMount(source: string, options?: {
isReadOnly?: boolean;
}): SeaweedFSContainerResource (+1 overload)

Adds a bind mount for the SeaweedFS data folder.

withDataBindMount
('./data/seaweedfs');
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

Named volumes persist data without depending on a host path. Bind mounts are useful during development when you need to inspect or edit host files directly.

Call WithS3ConfigFile after enabling S3 to mount a custom configuration file read-only at /etc/seaweedfs/s3-custom.json. The method throws if WithS3 has not been called:

apphost.mts
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.withS3ConfigFile(configFilePath: string): SeaweedFSContainerResource

Configures the SeaweedFS S3 API to use a specific external security configuration file.

withS3ConfigFile
('./seaweedfs/s3.json');
await
const builder: IDistributedApplicationBuilder
builder
.
IDistributedApplicationBuilder.build(): DistributedApplication

Builds the distributed application

build
().
DistributedApplication.run(cancellationToken?: cancellationToken): void

Runs the distributed application

run
();

The custom file replaces the generated S3 identity configuration. Define the desired identities and credentials in that file. The AppHost still exposes its credential parameters in the connection string; set WithAccessKey and WithSecretKey to credentials matching an identity in the file.

The integration adds a SeaweedFS health check that queries the Master API at /dir/status with Accept: application/json. It requires a successful response containing a non-zero Topology.Max value, which indicates that the Volume Server has registered storage capacity. A running Master alone is not considered ready. This probe does not separately check the S3 or Filer APIs.

With both S3 and Filer enabled, referencing the resource creates a connection string with this shape:

Endpoint=http://{s3-host}:{s3-port};AccessKey={key};SecretKey={secret};FilerEndpoint=http://{filer-host}:{filer-port}

Endpoint points to the S3 API when enabled, or the Master API otherwise. The connection properties include Host, Port, and MasterUrl; S3Url, AccessKey, and SecretKey are available when S3 is enabled; FilerUrl is available when Filer is enabled. See Connect to SeaweedFS for client configuration.

  • AddSeaweedFS(name) creates the base Master and Volume resource.
  • WithS3(s3Port) enables the S3 gateway and implicitly enables Filer.
  • WithFiler(filerPort) enables the native Filer API.
  • WithHostPort(port) selects the Master API host port.
  • WithAccessKey(parameter) and WithSecretKey(parameter) select custom S3 credential parameters.
  • WithS3ConfigFile(configFilePath) mounts a custom S3 configuration file. Call it after enabling S3.
  • WithDataBindMount(source, isReadOnly) mounts a host directory at /data.
  • WithDataVolume(name, isReadOnly) mounts a named volume at /data.

All listed APIs are exported to TypeScript AppHosts with their corresponding camel-case names.