Polyglot AppHost
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).
How it works
Section titled “How it works”When you create a polyglot AppHost:
- The Aspire CLI scaffolds a language-specific AppHost project
- A .NET AppHost Server runs in the background, handling orchestration
- Your code communicates with the server via JSON-RPC over Unix sockets (or named pipes on Windows)
- 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.
Prerequisites
Section titled “Prerequisites”Before creating a polyglot AppHost, ensure you have the following installed:
Required for all languages
Section titled “Required for all languages”| Requirement | Version | Notes |
|---|---|---|
| .NET SDK | 10.0+ | Required for the AppHost server |
| Aspire CLI | Latest | Install using the install script |
| Docker | Latest | Required for container resources |
Language-specific setup
Section titled “Language-specific setup”Select your preferred language to see the specific requirements and setup instructions:
Runtime requirements
Section titled “Runtime requirements”| Requirement | Version | Notes |
|---|---|---|
| Node.js | 20+ | LTS version recommended |
| npm or pnpm | Latest | Package manager |
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.10+ | python3 or python command |
| uv | Latest | Python package manager |
Install uv if not already installed:
curl -LsSf https://astral.sh/uv/install.sh | sh| Requirement | Version | Notes |
|---|---|---|
| Go | 1.23+ | Required for module support |
| Requirement | Version | Notes |
|---|---|---|
| Rust | Latest stable | Via rustup |
| Cargo | Latest | Included with Rust |
| Requirement | Version | Notes |
|---|---|---|
| Java JDK | 17+ | OpenJDK/Temurin recommended |
Create an AppHost
Section titled “Create an AppHost”The following steps demonstrate how to create a new polyglot AppHost for your preferred language.
-
Create a new directory and initialize the AppHost:
Initialize TypeScript AppHost mkdir my-apphost && cd my-apphostaspire init -l typescript -
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
-
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();
-
Create a new directory and initialize the AppHost:
Initialize Python AppHost mkdir my-apphost && cd my-apphostaspire init -l python -
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
-
Review the generated
apphost.py:apphost.py import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent / ".modules"))from aspire import create_builderbuilder = create_builder()# Add your resources here, for example:# redis = builder.add_redis("cache")# postgres = builder.add_postgres("db")builder.build().run()
-
Create a new directory and initialize the AppHost:
Initialize Go AppHost mkdir my-apphost && cd my-apphostaspire init -l go -
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
-
Review the generated
apphost.go:apphost.go package mainimport ("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)}}
-
Create a new directory and initialize the AppHost:
Initialize Rust AppHost mkdir my-apphost && cd my-apphostaspire init -l rust -
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
-
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(())}
-
Create a new directory and initialize the AppHost:
Initialize Java AppHost mkdir my-apphost && cd my-apphostaspire init -l java -
The following project structure is created:
Directorymy-apphost/
Directory.aspire/
- settings.json
Directory.modules/ Generated SDK
- …
- AppHost.java Your AppHost code
- apphost.run.json
-
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);}}}
Add Redis integration
Section titled “Add Redis integration”-
Add the Redis integration:
Add Redis aspire add Aspire.Hosting.Redis -
Update
apphost.tsto use Redis:apphost.ts import { createBuilder } from './.modules/aspire.js';const builder = await createBuilder();// Add Redis cache resourceconst redis = builder.addRedis('cache');const app = builder.build();await app.run(); -
Run the AppHost:
Run AppHost aspire run
-
Add the Redis integration:
Add Redis aspire add Aspire.Hosting.Redis -
Update
apphost.pyto use Redis:apphost.py import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent / ".modules"))from aspire import create_builderbuilder = create_builder()# Add Redis cache resourceredis = builder.add_redis("cache")builder.build().run() -
Run the AppHost:
Run AppHost aspire run
-
Add the Redis integration:
Add Redis aspire add Aspire.Hosting.Redis -
Update
apphost.goto use Redis:apphost.go package mainimport ("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)}} -
Run the AppHost:
Run AppHost aspire run
-
Add the Redis integration:
Add Redis aspire add Aspire.Hosting.Redis -
Update
src/main.rsto 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(())} -
Run the AppHost:
Run AppHost aspire run
-
Add the Redis integration:
Add Redis aspire add Aspire.Hosting.Redis -
Update
AppHost.javato 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 passwordbuilder.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);}}} -
Run the AppHost:
Run AppHost aspire run
Adding integrations
Section titled “Adding integrations”To add Aspire hosting integrations to your polyglot AppHost, use the aspire add command:
# Add PostgreSQLaspire add postgreSQL
# Add RabbitMQaspire add rabbitmq
# Add Azure Storageaspire add azure_storageWhen you add an integration, the Aspire CLI:
- Updates
.aspire/settings.jsonwith the package reference - Regenerates the language-specific SDK in the
.modulesdirectory - Makes the new APIs available in your AppHost code
Explore all available integrations or see the aspire add reference.
Troubleshooting
Section titled “Troubleshooting”If you encounter issues with your polyglot AppHost, this section provides guidance on diagnosing and resolving common problems.
Common issues
Section titled “Common issues”Here are solutions to common problems you may encounter when working with polyglot AppHosts.
”Command not found” errors
Section titled “”Command not found” errors”Ensure the language runtime is installed and available in your PATH:
node --versionnpm --versionnode --versionnpm --versionpython3 --versionuv --versionpython --versionuv --versiongo versiongo versionrustc --versioncargo --versionrustc --versioncargo --versionjava -versionjava -version“Polyglot support not enabled”
Section titled ““Polyglot support not enabled””Enable polyglot support in the Aspire CLI configuration:
aspire config set features:polyglotSupportEnabled true --globalSDK compilation errors
Section titled “SDK compilation errors”If you encounter compilation errors in the generated SDK:
- Ensure you have the latest version of the Aspire CLI installed
- Delete the
.modulesdirectory and runaspire runagain to regenerate the SDK - Check the Aspire GitHub issues for known problems
Debug mode
Section titled “Debug mode”Run with debug output to diagnose issues:
aspire run --debugSee the aspire run command reference.
Check logs
Section titled “Check logs”Aspire CLI logs are stored at:
~/.aspire/cli/logs/%USERPROFILE%\.aspire\cli\logs\Feedback
Section titled “Feedback”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