.NET Aspire is based on a previous experiment from Microsoft called Project Tye
which was release around May 2020.
The goal of .NET Aspire is to improve the local development experience for Distributed Applications (aka microservices). In a nutshell, .NET Aspire helps to improve:
The great thing about a .NET Aspire orchestrated application is that we can add all the Projects / Services and Components that make up our overall microservices system into one project and have a way to describe how the applications are connected or related to each other.
var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedisContainer("cache");
var heroApi = builder.AddProject<Projects.AspiringHeroes_Api>("heroesRestAPI");
var heroGrpc = builder.AddProject<Projects.AspiringHeroes_Grpc>("heroesGrpcService");
builder.AddProject<Projects.AspiringHeroes_Web>("webUI")
.WithReference(cache)
.WithReference(heroApi)
.WithReference(heroGrpc);
builder.Build().Run();
The AppHost
and ServiceDefaults
is responsible for all configuration that enables the health checking, resiliency, service discovery, telemetry and more.
Figure: Using C# to describe the projects and components in the distributed system and how they are related to each other.
Figure: Aspire Dashboard - Projects View
Figure: Aspire Dashboard - Traces View
Figure: Aspire Dashboard - Trace Details View
launchSettings.json
.NET Aspire allows for flexible deployment of applications across platforms that support .NET and containers. It generates a manifest file to help deployment tools understand the app's structure, which includes information about the projects and dependant services along with the necessary properties for deployment like environment variables and network bindings.
In summary, .NET Aspire simplifies app deployment across various platforms. It works well with containerized environments and integrates with tools like AZD and Aspirate for a streamlined deployment process.
Azure Container Apps (ACA) is a great choice for hosting .NET Aspire applications. ACA is a managed environment for running containerised applications on a serverless platform.
The Azure Developer CLI (AZD) is used to generate an Azure Bicep, a language for describing and deploying Azure resources. This is used to provision Azure Container Apps resources needed to host .NET Aspire applications. AZD can also directly deploy the application to Azure Container Apps.
Check out the in-depth guide for how to synthesize the Azure Bicep file that you can use as part of your GitHub workflow / Azure DevOps pipeline to automate everything.
Using AZD, the steps to get a .NET Aspire application deployed from local to Azure Container Apps can be distilled to the following 3 commands:
azd auth login
azd init
azd up
Quite simple right? Ofcourse we would really want to take it further and use automated CI/CD workflows to do the work for us.
Azure Kubernetes Service (AKS) is an managed environment for running container applications with advanced networking and orchestration capabilities.
Using the Aspirate tool we can generate Kubernetes Manifest files for each component in our .NET Aspire application and eventually push the application containers to a container registry and then deploy to pods on a AKS/K8s cluster.
For detailed steps on how to deploy your application to AKS/K8s, check out the Deploy .NET Aspire apps to a Kubernetes cluster page from MS Learn (its a lot easier than you think).
.NET Aspire announcement: https://devblogs.microsoft.com/dotnet/announcing-dotnet-8
Aspire Samples on GitHub: https://github.com/dotnet/aspire-samples