Introduction
.NET Aspire is a cloud-ready stack designed to simplify the development of resilient, observable, and production-ready distributed applications using the .NET framework. It provides a curated set of tools and libraries that address common cloud-native concerns, making it easier for developers to build and manage complex applications.
There are three main parts in .NET Aspire,
- Integrations
- Nuget packages for many services like databases and Caches.
- Orchestration
- Run distributed application locally, use placeholder instead of host names/connection string.
- Templates
- Visual Studio
- .NET CLI
Pre-requisites
- .NET 8+
- .NET Aspire workload.
- Visual Studio 2022 17.10+, VS Code, JetBrain Rider
- Docker
Create a .NET Aspire Application
I’m using Visual Studio .NET Aspire starter template to create a .NET Aspire application.

Name your application as shown in the below figure.

You will get four projects (ApiService, AppHost, ServiceDefaults, Web) under one solution, shown in the figure below,

Run the AppHost project, and you will get a nice dashboard.

From this dashboard, you can navigate to console logs, Structures logs, request traces, and metrics of your project or application.
It’s a one-stop solution for all your application monitoring solutions. This will give you an excellent insight into your application.
AppHost project ties everything together, it does the orchestration and works with both web and API projects, and it’s a starter Host project.
Let’s analyze the AppHost project. Open Program.cs file

DistributedApplication class is something new with .NET Aspire it’s nothing but an implementation of IHost that orchestrates the .NET Aspire application, and in the next two statements will add ApiService and web projects with the magic strings. These strings are the identifiers that can be referenced in another project as well.
Open program.cs file from the web project

The base address of the httpclient, in our case the WeatherApiClient, the URL is “apiservice”.
For example, if this string is different for production like api.prod.apiservices the same host name should be configured here. .NET Aspire makes sure that the API once deployed also runs on that host. So that’s why we have these strings.
Integrations
Let’s see how simple to add a Redis Cache component.
Add below package in the web project
dotnet add package Aspire.StackExchange.Redis.OutputCaching open program.cs file from Web project and add below code to configure Redis output Cache.
builder.AddRedisOutputCache("cache");Add below package in AppHost project.
dotnet add package Aspire.Hosting.RedisOpen program.cs file from the AppHost project and add Redis configuration.
var cache = builder.AddRedis("cache");builder.AddProject<Projects.Aspiredemo_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService)
.WithReference(cache);Add a cache reference for webfrontend
Run the application to ensure the redis cache implementation is working.
Note : Local Docker should be in running status.

From the above screenshot it’s obvious, as per our configuration the redis cache container service is up and running.

The above high level flow diagram gives you the complete idea about how the .NET Aspire Orchestrate the multiple projects.
Deployment
.NET Aspire deployment is pretty simple from Visual Studio to Azure as a container service, just right-click on the Host project.
Note: Ensure you have a latest version of Azure developer CLI

Select Azure Container Apps for .NET Aspire template and click on next

Provide the Enviornmenr name and click on Finish and publish.

The above screenshot will provide you the details of list of resources has been created for the deployment.

Summary
In this article, we have seen how to get start with .NET Aspire, starting with an introduction to its core features and benefits. We then guide you through the process of creating a .NET Aspire application using Visual Studio, highlighting key steps. Next, we cover the creation of components within the application, providing detailed instructions and examples. Finally, we discuss the deployment process, ensuring your .NET Aspire application is ready for production.