Set up Seq in the AppHost
This article is the reference for the Aspire Seq hosting integration. It enumerates the AppHost APIs — with examples for both AppHost.cs and apphost.ts — that you use to model a Seq server resource in your AppHost project.
If you’re new to the Seq integration, start with the Get started with Seq integrations guide. For how consuming apps read the connection information this page exposes, see Connect to Seq.
Installation
Section titled “Installation”To start building an Aspire app that uses Seq, install the 📦 Aspire.Hosting.Seq NuGet package:
aspire add seqLearn more about aspire add in the command reference.
Or, choose a manual installation approach:
#:package Aspire.Hosting.Seq@*<PackageReference Include="Aspire.Hosting.Seq" Version="*" />aspire add seqLearn more about aspire add in the command reference.
This updates your aspire.config.json with the Seq hosting integration package:
{ "packages": { "Aspire.Hosting.Seq": "13.3.0" }}Add Seq resource
Section titled “Add Seq resource”Once you’ve installed the hosting integration in your AppHost project, you can add a Seq resource as shown in the following examples:
var builder = DistributedApplication.CreateBuilder(args);
var seq = builder.AddSeq("seq") .ExcludeFromManifest() .WithLifetime(ContainerLifetime.Persistent) .WithEnvironment("ACCEPT_EULA", "Y");
var myService = builder.AddProject<Projects.ExampleProject>() .WithReference(seq) .WaitFor(seq);
// After adding all resources, run the app...import { createBuilder, ContainerLifetime } from './.modules/aspire.js';
const builder = await createBuilder();
const adminPassword = await builder.addParameter("seq-admin-password", { secret: true });const seq = await builder.addSeq("seq", adminPassword);await seq.withLifetime(ContainerLifetime.Persistent);await seq.withEnvironment("ACCEPT_EULA", "Y");
await builder.addNodeApp("api", "./api", "index.js") .withReference(seq) .waitFor(seq);
// After adding all resources, run the app...-
When Aspire adds a container image to the AppHost, as shown in the preceding example with the
docker.io/datalust/seqimage, it creates a new Seq instance on your local machine. -
The Seq container may be slow to start, so it’s best to use a persistent lifetime to avoid unnecessary restarts. For more information, see Container resource lifetime.
-
The AppHost reference call configures a connection in the consuming project named after the referenced Seq resource, such as
seqin the preceding example.
Accept the Seq End User License Agreement (EULA)
Section titled “Accept the Seq End User License Agreement (EULA)”You must accept the Seq EULA for Seq to start. Pass the ACCEPT_EULA environment variable with a value of Y to the Seq container to accept the agreement in code, as shown in the examples above.
Seq in the Aspire manifest
Section titled “Seq in the Aspire manifest”Seq is an observability tool intended for local development and internal environments. Call ExcludeFromManifest (C#) to prevent the Seq resource from appearing in the Aspire deployment manifest. Set up a secure, production-grade Seq server outside of Aspire for your production environment.
Add Seq resource with data volume
Section titled “Add Seq resource with data volume”Add a data volume to the Seq resource to persist log data across container restarts:
var builder = DistributedApplication.CreateBuilder(args);
var seq = builder.AddSeq("seq") .WithDataVolume() .ExcludeFromManifest() .WithLifetime(ContainerLifetime.Persistent) .WithEnvironment("ACCEPT_EULA", "Y");
var myService = builder.AddProject<Projects.ExampleProject>() .WithReference(seq) .WaitFor(seq);
// After adding all resources, run the app...The TypeScript AppHost doesn’t currently expose a withDataVolume(...) API for Seq. To persist Seq data from a TypeScript AppHost, use withBindMount to map a host directory into the container at /data instead.
The data volume is used to persist the Seq data outside the lifecycle of its container. The data volume is mounted at /data in the Seq container, and when a name parameter isn’t provided, the name is generated at random. For more information on data volumes and details on why they’re preferred over bind mounts, see Docker docs: Volumes.
Add Seq resource with data bind mount
Section titled “Add Seq resource with data bind mount”Add a data bind mount to the Seq resource as shown in the following examples:
var builder = DistributedApplication.CreateBuilder(args);
var seq = builder.AddSeq("seq") .WithDataBindMount(source: "/Seq/Data", isReadOnly: false) .ExcludeFromManifest() .WithLifetime(ContainerLifetime.Persistent) .WithEnvironment("ACCEPT_EULA", "Y");
var myService = builder.AddProject<Projects.ExampleProject>() .WithReference(seq) .WaitFor(seq);
// After adding all resources, run the app...import { createBuilder, ContainerLifetime } from './.modules/aspire.js';
const builder = await createBuilder();
const adminPassword = await builder.addParameter("seq-admin-password", { secret: true });const seq = await builder.addSeq("seq", adminPassword);await seq.withBindMount("/Seq/Data", "/data", { isReadOnly: false });await seq.withLifetime(ContainerLifetime.Persistent);await seq.withEnvironment("ACCEPT_EULA", "Y");
await builder.addNodeApp("api", "./api", "index.js") .withReference(seq) .waitFor(seq);
// After adding all resources, run the app...Data bind mounts rely on the host machine’s filesystem to persist Seq data across container restarts. The bind mount is mounted at /data in the Seq container, and maps to C:\Seq\Data on Windows (or /Seq/Data on Unix) on the host machine. For more information on data bind mounts, see Docker docs: Bind mounts.
Seq endpoints
Section titled “Seq endpoints”The Seq container exposes two endpoints:
| Endpoint | Default port | Description |
|---|---|---|
http | 5341 | The primary ingestion and query endpoint used by consuming apps and the Seq web UI |
When you call .WithReference(seq), Aspire injects the http endpoint URI into the consuming app as the SEQ_URI environment variable (or {RESOURCE}_URI for other resource names).
Connection properties
Section titled “Connection properties”For the full reference of Seq connection properties — and how consuming apps in C#, TypeScript, Python, and Go read them — see Connect to Seq.
Hosting integration health checks
Section titled “Hosting integration health checks”The Seq hosting integration does not automatically register a health check. Seq availability is typically verified by the consuming app’s client integration or by using .WaitFor(seq) in the AppHost to delay dependent resources until the Seq container is ready.