.NET Aspire

.NET Aspire is an opinionated, cloud ready stack for building observable, production ready, distributed applications. .NET Aspire is delivered through a collection of NuGet packages that handle specific cloud-native concerns. Cloud-native apps often consist of small, interconnected pieces or microservices rather than a single, monolithic code base. Cloud-native apps generally consume a large number of services, such as databases, messaging and caching.

What is .NET Aspire

Why .NET Aspire

.NET Aspire is designed to improve the experience of building .NET cloud-native apps. It provides a consistent, opinionated set of tools and patterns that help you build and run distributed apps. .NET Aspire is designed to help you with:

  • Orchestration: .NET Aspire provides features for running and connecting multi-project applications and their dependencies.
  • Components: .NET Aspire components are NuGet packages for commonly used services, such as Redis or Postgres, with standardized interfaces ensuring they connect consistently and seamlessly with your app.
  • Tooling: .NET Aspire comes with project templates and tooling experiences for Visual Studio and the dotnet CLI help you create and interact with .NET Aspire apps.
     

Frequently asked questions

  • Why use .NET Aspire for orchestration when I can use Docker Compose?

  • Why would I use .NET Aspire service discovery when Docker Compose has it built in and works with Kubernetes?

  • Why is there a need for a yet another framework to do what's already being done very well by everyone else?
  • When will .NET Aspire be released?

How to start working with
.NET Aspire?

Installing Aspire workload in VS 2022

//Check different .net workloads
dotnet workload list

//install dotnet workload
dotnet workload install aspire

//Update your Aspire worload 
dotnet workload update

Installing Aspire workload via .NET cli

Create and Run .NET Aspire project

//Create project
dotnet new aspire-starter 
  --use-redis-cache --output AspireSample
//or empty Aspire project
dotnet new aspire AspireSample

//Run
dotnet run --project AspireSample/AspireSample.AppHost 

Create and Run .NET Aspire project via CLI

└───📂 AspireSample
     ├───📂 AspireSample.ApiService
     │    ├───📂 Properties
     │    │    └─── launchSettings.json
     │    ├─── appsettings.Development.json
     │    ├─── appsettings.json
     │    ├─── AspireSample.ApiService.csproj
     │    └─── Program.cs
     ├───📂 AspireSample.AppHost
     │    ├───📂 Properties
     │    │    └─── launchSettings.json
     │    ├─── appsettings.Development.json
     │    ├─── appsettings.json
     │    ├─── AspireSample.AppHost.csproj
     │    └─── Program.cs
     ├───📂 AspireSample.ServiceDefaults
     │    ├─── AspireSample.ServiceDefaults.csproj
     │    └─── Extensions.cs
     ├───📂 AspireSample.Web
     │    ├───📂 Components
     │    │    ├───📂 Layout
     │    │    │    ├─── MainLayout.razor
     │    │    │    ├─── MainLayout.razor.css
     │    │    │    ├─── NavMenu.razor
     │    │    │    └─── NavMenu.razor.css
     │    │    ├───📂 Pages
     │    │    │    ├─── Counter.razor
     │    │    │    ├─── Error.razor
     │    │    │    ├─── Home.razor
     │    │    │    └─── Weather.razor
     │    │    ├─── _Imports.razor
     │    │    ├─── App.razor
     │    │    └─── Routes.razor
     │    ├───📂 Properties
     │    │    └─── launchSettings.json
     │    ├───📂 wwwroot
     │    │    ├───📂 bootstrap
     │    │    │    ├─── bootstrap.min.css
     │    │    │    └─── bootstrap.min.css.map
     │    │    ├─── app.css
     │    │    └─── favicon.png
     │    ├─── appsettings.Development.json
     │    ├─── appsettings.json
     │    ├─── AspireSample.Web.csproj
     │    ├─── Program.cs
     │    └─── WeatherApiClient.cs
     └─── AspireSample.sln

.NET Aspire project directories

How to deploy .NET Aspire project ?

.NET Aspire apps are designed to run in containerized environments. Azure Container Apps is a fully managed environment that enables you to run microservices and containerized applications on a serverless platform.

  • Azure Bicep
  • Azure CLI
  • Azure Developer CLI(azd)

How azd up work ?

Common azd commands to deploy

//Initialize azd deployment
azd init
//Login to Azure tenant
azd auth login
//azd provision and azd deploy will be executed
azd up
//Deploy changes
azd deploy
//Deploy specific projects
azd deploy webfrontend

{demo}

.NET Aspire

By Ryan Niño Dizon

.NET Aspire

  • 12