Skip to content
Docs Try Aspire
Preview feature

Aspire’s polyglot support allows you to write AppHosts in languages other than C#. This enables teams to use their preferred programming language while still benefiting from Aspire’s orchestration capabilities, including access to 40+ hosting integrations (Redis, PostgreSQL, Azure services, and more).

When you create a polyglot AppHost:

  1. The Aspire CLI scaffolds a language-specific AppHost project
  2. A .NET AppHost Server runs in the background, handling orchestration
  3. Your code communicates with the server via JSON-RPC over Unix sockets (or named pipes on Windows)
  4. The server manages containers, service discovery, and the Aspire Dashboard
flowchart LR
    subgraph YourCode["Your Code"]
        TS["TypeScript"]
        PY["Python"]
        GO["Go"]
        RS["Rust"]
        JV["Java"]
    end

    subgraph Server[".NET AppHost Server"]
        RPC["JSON-RPC"]
        ORCH["Orchestration"]
        SD["Service Discovery"]
    end

    subgraph Resources["Managed Resources"]
        DASH["Aspire Dashboard"]
        CONT["Containers"]
        INT["40+ Integrations"]
    end

    TS & PY & GO & RS & JV --> RPC
    RPC --> ORCH
    ORCH --> SD
    SD --> DASH & CONT & INT

This architecture gives you access to the full power of Aspire’s orchestration while writing code in your preferred language.

Before creating a polyglot AppHost, ensure you have the following installed:

RequirementVersionNotes
.NET SDK10.0+Required for the AppHost server
Aspire CLILatestInstall using the install script
DockerLatestRequired for container resources

Select your preferred language to see the specific requirements and setup instructions:

Select your language
RequirementVersionNotes
Node.js20+LTS version recommended
npm or pnpmLatestPackage manager
RequirementVersionNotes
Python3.10+python3 or python command
uvLatestPython package manager

Install uv if not already installed:

Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
RequirementVersionNotes
Go1.23+Required for module support
RequirementVersionNotes
RustLatest stableVia rustup
CargoLatestIncluded with Rust
RequirementVersionNotes
Java JDK17+OpenJDK/Temurin recommended

The following steps demonstrate how to create a new polyglot AppHost for your preferred language.

  1. Create a new directory and initialize the AppHost:

    Initialize TypeScript AppHost
    mkdir my-apphost && cd my-apphost
    aspire init -l typescript
  2. The following project structure is created:

    • Directorymy-apphost/
      • Directory.aspire/
        • settings.json
      • Directory.modules/ Generated SDK (created on first run)
      • apphost.ts Your AppHost code
      • apphost.run.json
      • package.json
      • tsconfig.json
  3. Review the generated apphost.ts:

    apphost.ts
    import { createBuilder } from './.modules/aspire.js';
    const builder = await createBuilder();
    // Add your resources here, for example:
    // const redis = builder.addRedis("cache");
    // const postgres = builder.addPostgres("db");
    const app = builder.build();
    await app.run();
  1. Create a new directory and initialize the AppHost:

    Initialize Python AppHost
    mkdir my-apphost && cd my-apphost
    aspire init -l python
  2. The following project structure is created:

    • Directorymy-apphost/
      • Directory.aspire/
        • settings.json
      • Directory.modules/ Generated SDK (created on first run)
      • apphost.py Your AppHost code
      • apphost.run.json
      • requirements.txt
      • uv-install.py
  3. Review the generated apphost.py:

    apphost.py
    import sys
    from pathlib import Path
    sys.path.insert(0, str(Path(__file__).parent / ".modules"))
    from aspire import create_builder
    builder = create_builder()
    # Add your resources here, for example:
    # redis = builder.add_redis("cache")
    # postgres = builder.add_postgres("db")
    builder.build().run()
  1. Create a new directory and initialize the AppHost:

    Initialize Go AppHost
    mkdir my-apphost && cd my-apphost
    aspire init -l go
  2. The following project structure is created:

    • Directorymy-apphost/
      • Directory.aspire/
        • settings.json
      • Directory.modules/ Generated SDK
      • apphost.go Your AppHost code
      • apphost.run.json
      • go.mod
  3. Review the generated apphost.go:

    apphost.go
    package main
    import (
    "log"
    "apphost/modules/aspire"
    )
    func main() {
    builder, err := aspire.CreateBuilder(nil)
    if err != nil {
    log.Fatalf("Failed to create builder: %v", err)
    }
    // Add your resources here, for example:
    // redis, _ := builder.AddRedis("cache", 0, nil)
    // postgres, _ := builder.AddPostgres("db", 0, nil, nil)
    app, err := builder.Build()
    if err != nil {
    log.Fatalf("Failed to build: %v", err)
    }
    if err := app.Run(nil); err != nil {
    log.Fatalf("Failed to run: %v", err)
    }
    }
  1. Create a new directory and initialize the AppHost:

    Initialize Rust AppHost
    mkdir my-apphost && cd my-apphost
    aspire init -l rust
  2. The following project structure is created:

    • Directorymy-apphost/
      • Directory.aspire/
        • settings.json
      • Directory.modules/ Generated SDK
      • apphost.rs Marker file
      • apphost.run.json
      • Cargo.toml
      • Directorysrc/
        • main.rs Your AppHost code
  3. Review the generated src/main.rs:

    src/main.rs
    #[path = "../.modules/mod.rs"]
    mod aspire;
    use aspire::*;
    fn main() -> Result<(), Box<dyn std::error::Error>> {
    let builder = create_builder(None)?;
    // Add your resources here, for example:
    // let redis = builder.add_redis("cache", None, None)?;
    // let postgres = builder.add_postgres("db", None, None, None)?;
    let app = builder.build()?;
    app.run(None)?;
    Ok(())
    }
  1. Create a new directory and initialize the AppHost:

    Initialize Java AppHost
    mkdir my-apphost && cd my-apphost
    aspire init -l java
  2. The following project structure is created:

    • Directorymy-apphost/
      • Directory.aspire/
        • settings.json
      • Directory.modules/ Generated SDK
      • AppHost.java Your AppHost code
      • apphost.run.json
  3. Review the generated AppHost.java:

    AppHost.java
    package aspire;
    public class AppHost {
    public static void main(String[] args) {
    try {
    IDistributedApplicationBuilder builder = Aspire.createBuilder(null);
    // Add your resources here, for example:
    // var redis = builder.addRedis("cache", null, null);
    // var postgres = builder.addPostgres("db", null, null, null);
    DistributedApplication app = builder.build();
    app.run(null);
    } catch (Exception e) {
    System.err.println("Failed to run: " + e.getMessage());
    e.printStackTrace();
    System.exit(1);
    }
    }
    }
  1. Add the Redis integration:

    Add Redis
    aspire add Aspire.Hosting.Redis
  2. Update apphost.ts to use Redis:

    apphost.ts
    import { createBuilder } from './.modules/aspire.js';
    const builder = await createBuilder();
    // Add Redis cache resource
    const redis = builder.addRedis('cache');
    const app = builder.build();
    await app.run();
  3. Run the AppHost:

    Run AppHost
    aspire run
  1. Add the Redis integration:

    Add Redis
    aspire add Aspire.Hosting.Redis
  2. Update apphost.py to use Redis:

    apphost.py
    import sys
    from pathlib import Path
    sys.path.insert(0, str(Path(__file__).parent / ".modules"))
    from aspire import create_builder
    builder = create_builder()
    # Add Redis cache resource
    redis = builder.add_redis("cache")
    builder.build().run()
  3. Run the AppHost:

    Run AppHost
    aspire run
  1. Add the Redis integration:

    Add Redis
    aspire add Aspire.Hosting.Redis
  2. Update apphost.go to use Redis:

    apphost.go
    package main
    import (
    "log"
    "apphost/modules/aspire"
    )
    func main() {
    builder, err := aspire.CreateBuilder(nil)
    if err != nil {
    log.Fatalf("Failed to create builder: %v", err)
    }
    // Add Redis cache resource (name, port, password)
    // Use 0 for default port, nil for no password
    _, err = builder.AddRedis("cache", 0, nil)
    if err != nil {
    log.Fatalf("Failed to add Redis: %v", err)
    }
    app, err := builder.Build()
    if err != nil {
    log.Fatalf("Failed to build: %v", err)
    }
    if err := app.Run(nil); err != nil {
    log.Fatalf("Failed to run: %v", err)
    }
    }
  3. Run the AppHost:

    Run AppHost
    aspire run
  1. Add the Redis integration:

    Add Redis
    aspire add Aspire.Hosting.Redis
  2. Update src/main.rs to use Redis:

    src/main.rs
    #[path = "../.modules/mod.rs"]
    mod aspire;
    use aspire::*;
    fn main() -> Result<(), Box<dyn std::error::Error>> {
    let builder = create_builder(None)?;
    // Add Redis cache resource (name, port, password)
    builder.add_redis("cache", None, None)?;
    let app = builder.build()?;
    app.run(None)?;
    Ok(())
    }
  3. Run the AppHost:

    Run AppHost
    aspire run
  1. Add the Redis integration:

    Add Redis
    aspire add Aspire.Hosting.Redis
  2. Update AppHost.java to use Redis:

    AppHost.java
    package aspire;
    public class AppHost {
    public static void main(String[] args) {
    try {
    IDistributedApplicationBuilder builder = Aspire.createBuilder(null);
    // Add Redis cache resource (name, port, password)
    // Use null for default port and no password
    builder.addRedis("cache", null, null);
    DistributedApplication app = builder.build();
    app.run(null);
    } catch (Exception e) {
    System.err.println("Failed to run: " + e.getMessage());
    e.printStackTrace();
    System.exit(1);
    }
    }
    }
  3. Run the AppHost:

    Run AppHost
    aspire run

To add Aspire hosting integrations to your polyglot AppHost, use the aspire add command:

Add integrations
# Add PostgreSQL
aspire add postgreSQL
# Add RabbitMQ
aspire add rabbitmq
# Add Azure Storage
aspire add azure_storage

When you add an integration, the Aspire CLI:

  1. Updates .aspire/settings.json with the package reference
  2. Regenerates the language-specific SDK in the .modules directory
  3. Makes the new APIs available in your AppHost code

If you encounter issues with your polyglot AppHost, this section provides guidance on diagnosing and resolving common problems.

Here are solutions to common problems you may encounter when working with polyglot AppHosts.

Ensure the language runtime is installed and available in your PATH:

Verify Node.js installation
node --version
npm --version
Verify Python installation
python3 --version
uv --version
Verify Go installation
go version
Verify Rust installation
rustc --version
cargo --version
Verify Java installation
java -version

Enable polyglot support in the Aspire CLI configuration:

Enable polyglot support
aspire config set features:polyglotSupportEnabled true --global

If you encounter compilation errors in the generated SDK:

  1. Ensure you have the latest version of the Aspire CLI installed
  2. Delete the .modules directory and run aspire run again to regenerate the SDK
  3. Check the Aspire GitHub issues for known problems

Run with debug output to diagnose issues:

Run with debug output
aspire run --debug

Aspire CLI logs are stored at:

Terminal window
~/.aspire/cli/logs/

Polyglot AppHost support is a preview feature. Your feedback helps us improve language support and prioritize new features. Please share your experiences, suggestions, and bug reports on the Aspire GitHub repository.

When reporting issues, please include:

  • The language you’re using
  • The Aspire CLI version (aspire --version)
  • The language runtime version
  • Steps to reproduce the issue
  • Any error messages or logs