Gå til indhold
DocsTry Aspire
DocsTry

Set up Deno apps in the AppHost

Dette indhold er ikke tilgængeligt i dit sprog endnu.

⭐ Community Toolkit Deno logo

This reference covers the Deno AppHost API from the Aspire Community Toolkit. For an introduction, see Get started with the Deno integration.

Install the hosting package in your AppHost:

Aspire CLI — Tilføj CommunityToolkit.Aspire.Hosting.Deno-pakke
aspire add communitytoolkit-deno

Aspire CLI er interaktiv; vælg det passende søgeresultat når du bliver spurgt:

Aspire CLI — Eksempel output
Select an integration to add:
> communitytoolkit-deno (CommunityToolkit.Aspire.Hosting.Deno)
> Other results listed as selectable options...

The Deno executable must be available on PATH when Aspire runs the resource.

AddDenoApp / addDenoApp creates an executable resource that runs deno run, followed by permission flags, the script path, and application arguments.

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddDenoApp(
name: "deno-api",
scriptPath: "main.ts",
workingDirectory: "../deno-api",
permissionFlags: ["--allow-env", "--allow-net"],
args: ["--verbose"]);
builder.Build().Run();

name identifies the dashboard resource. scriptPath is passed to deno run. workingDirectory is resolved from the AppHost directory; when omitted, it defaults to ../<name>. permissionFlags and args are optional arrays. Use Deno permission flags appropriate to the application, such as --allow-net for network access and --allow-env when it reads environment variables.

Script resources set DENO_ENV to development in the development environment and production otherwise. They also configure the OTLP exporter.

AddDenoTask / addDenoTask runs deno task <taskName>, using the task configuration in the resource’s working directory.

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var web = builder.AddDenoTask(
name: "web",
workingDirectory: "../web",
taskName: "dev",
args: ["--host", "0.0.0.0"]);
builder.Build().Run();

taskName defaults to start; the working-directory default is also ../<name>. Task resources run the deno command with task, the task name, and the supplied arguments.

WithDenoPackageInstallation / withDenoPackageInstallation adds a deno install setup resource named <resource-name>-deno-install. The application waits for that setup resource to complete.

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddDenoApp("deno-api", "main.ts")
.WithDenoPackageInstallation();
builder.Build().Run();

In C#, an overload also accepts a callback that configures the installer resource. It is marked [AspireExportIgnore] because Action<IResourceBuilder<DenoInstallerResource>> is not ATS-compatible; TypeScript uses the exported overload without configureInstaller.

Configure endpoints, environment, and health checks

Section titled “Configure endpoints, environment, and health checks”

Deno resources are executable resources with endpoint, environment, argument, wait, and service-discovery support. Use the standard AppHost APIs to pass a listening port, configure additional environment variables, and define a probe:

AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddDenoApp(
"deno-api",
"main.ts",
permissionFlags: ["--allow-env", "--allow-net"])
.WithHttpEndpoint(port: 8000, env: "PORT")
.WithEnvironment("LOG_LEVEL", "debug")
.WithHttpHealthCheck("/health");
builder.Build().Run();

The application must read the PORT variable and listen on that port. It must also have the Deno permissions required to read its environment and serve network traffic. WithHttpHealthCheck / withHttpHealthCheck makes Aspire poll the specified HTTP path. Add WithEndpoint / withEndpoint when you need an additional endpoint definition, as in the Toolkit Deno samples.

The dashboard exposes the normal executable-resource lifecycle controls for Deno resources. Other AppHost resources can use WithReference / withReference and dependency APIs with a Deno resource because it supports service discovery. Add explicit endpoints before consumers need an address.

WithDenoPackageInstallation only creates its installer resource in run mode. The installer is excluded from the application manifest and is not created during publishing. The integration does not implement a Deno-specific container build or publish artifact; provide deployment packaging appropriate for your Deno application.

For deployment guidance, see the Aspire deployment overview.