Aspire Overview
Aspire streamlines building, running, and debugging distributed apps. Picture your app as a set of services, databases, and frontends—all working together seamlessly. With Aspire, you get a unified toolchain that eliminates complex configs and makes local debugging effortless. Instantly launch and debug your entire app with a single
The AppHost
Section titled “The AppHost”Aspire’s AppHost lets you define your app’s services and dependencies in code—no complex configs required. Easily map out your architecture and let Aspire handle the local orchestration, so you can focus on building features.
A simple example might represent a common three-tier architecture with a frontend that depends on an API, which in turn connects to a database:
This could be represented in the AppHost as shown in the following code:
import { createBuilder } from "./.modules/distributed-application";
const builder = createBuilder();
// Add database service to orbitconst postgres = builder.addPostgres("db").addDatabase("appdata");
// Add API service and reference the databaseconst api = builder.addProject("api", "../api/ApiService") .withReference(postgres);
// Add frontend service and reference the APIconst frontend = builder.addNpmApp("frontend", "../frontend") .withHttpEndpoint({ env: "PORT", targetPort: 3000 }) .withNpmPackageInstallation() .withReference(api);
builder.build().run();
from aspire import create_builder
builder = create_builder()
# Add database service to orbitpostgres = builder.add_postgres("db").add_database("appdata")
# Add API service and reference the databaseapi = builder.add_project("api", "../api/api_service.py") \ .with_reference(postgres)
# Add frontend service and reference the APIbuilder.add_npm_app("frontend", "../frontend") \ .with_http_endpoint(env="PORT", target_port=3000) \ .with_npm_package_installation() \ .with_reference(api)
# Launch your services into orbitbuilder.build().run()
var builder = DistributedApplication.CreateBuilder(args);
// Add database service to orbitvar postgres = builder.AddPostgres("db").AddDatabase("appdata");
// Add API service and reference the databasevar api = builder.AddProject("api", "../api/ApiService.csproj") .WithReference(postgres);
// Add frontend service and reference the APIvar frontend = builder.AddNpmApp("frontend", "../frontend") .WithHttpEndpoint(env: "PORT", targetPort: 3000) .WithNpmPackageInstallation() .WithReference(api);
builder.Build().Run();
Regardless of the language you choose, Aspire provides a consistent way to define your app’s architecture. You can easily add services, set up dependencies, and configure how they interact—all in a straightforward, code-first manner.
Modeled as Resources
Section titled “Modeled as Resources”Aspire makes it easy to define everything your app needs—frontends, APIs, databases, and more—using a unified AppHost model. Just describe your resources in code, and Aspire handles the connections for you. Resources can include:
- AI Services
- Caches
- Containers
- Databases
- Executables
- Frameworks
- Messaging Services
- Projects
- Storage
One resource can depend on another, and Aspire automatically wires them together. This means you can focus on building your app without worrying about the underlying infrastructure.
Reusable Composition
Section titled “Reusable Composition”When you compose your distributed app in Aspire’s AppHost, you’re not just defining services for local development and orchestration—you’re also setting up the foundation for deployment. The same composition you use to run and debug locally is leveraged when you publish your app, ensuring consistency from development through to production. Likewise, Aspire doesn’t get in the way of your existing deployment workflows.