Build your first Aspire app with a C# AppHost
This quickstart uses starter templates that generate a C# AppHost. Choose the app stack you want to start from, then create the solution, review the generated AppHost, and run it locally with Aspire.
Create a new app
To create your first Aspire application, use the Aspire CLI to generate a new solution from a starter template. These template include multiple projects, such as an API service, a web frontend, and an Aspire AppHost.
- 1
Create a new Aspire solution from a template:
The template provides several projects, including an API service, web frontend, and AppHost.
[!TIP] CLI flags The following flags are used in the command:
-n: specifies the name of the solution.-o: specifies the output directory.
If prompted for additional selections, use the and keys to navigate the options. Press to confirm your selection.
Review the template code
- 1
Examine the created template structure. The Aspire CLI creates a new folder with the name you provided in the current directory. This folder contains the solution file and several projects, including:
This solution structure is based on the Aspire templates. If they're not installed already, the CLI will install them for you.
- 2
Explore the AppHost code that orchestrates your app.
The AppHost is the heart of your Aspire application—it defines which services run, how they connect, and in what order they start. Let's look at the generated code:
[!NOTE] Code-first orchestration Your application topology is defined in code, making it easy to understand, modify, and version control. Learn more about the AppHost.
Run the app
- 1
Change to the output directory:
- 2
Call
aspire runto start dev-time orchestration:aspire runWhen you run this command, the Aspire CLI:
- Automatically finds the AppHost
- Builds your solution
- Launches dev-time orchestration
Once the dashboard is ready, its URL (with a login token—highlighted in the example output below) appears in your terminal. The dashboard provides a live, real-time view of your running resources and their current states.
- 3
Explore the running distributed application. From the dashboard, open the
HTTPSendpoint from each resource.
Stop the app
- 1
Stop the AppHost and close the dashboard by pressing in your terminal.
🛑 Stopping Aspire.Congratulations! You've created your first Aspire app.
See also
- Having trouble? Check out our Troubleshooting guide for solutions to common problems.
- Prefer a GUI? The Aspire VS Code extension lets you create, run, and debug Aspire apps from VS Code.