Building Cloud-Native App with .NET Aspire

What to expect from this workshop 

  • Let's talk about .NET Aspire

    • What, Why and How

  • Demo
    • Create and run .NET Aspire project
    • Explore .NET Aspire Dashboard
    • Build and deploy .NET Aspire to Azure
    • Add/Enable Application Insights to .NET Aspire Project
    • Test .NET Aspire with other modern UI Frameworks
    • Add .NET Aspire to existing app
  • Q & A

Ryan Niño Dizon

Software Development Lead / Software Architect

@ ISD Feniqs

github.com/ryannninodizon
youtube.com/@LearnWithJon
facebook.com/learnwithjonjon
medium.com/@ryanninodizon
linkedin.com/in/ryanninodizon
sessionize.com/ryanninodizon

What is Cloud-Native Applications?

Cloud native is an approach that uses technologies such as containers, Kubernetes, immutable infrastructure, and microservices to develop scalable applications that are built to run in the cloud

Four key principles of cloud-native development

Image source: https://www.techtarget.com/searchcloudcomputing/definition/cloud-native-application

Cloud-based vs Cloud native

Image source: https://www.cncf.io/blog/2023/09/04/cloud-based-versus-cloud-native-whats-the-difference/

What is .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.

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?

  • .NET 8.0
  • .NET Aspire workload
  • Docker Desktop
  • Integrated Developer Environment (IDE) or code editor, such as:
    • ​Visual Studio 2022 Preview version 17.9 or higher (Optional)
    • Visual Studio Code (Optional)


       

Installing Aspire workload in VS 2022

Installing Aspire workload via .NET CLI

//Check different .net workloads
dotnet workload list

//install dotnet workload
dotnet workload install aspire

//Update your Aspire worload 
dotnet workload update

Create .NET Aspire project

Create and Run .NET Aspire project via CLI

//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 

.NET Aspire project directories

└───📂 AspireSample
     ├───📂 AspireSample.ApiService
     │    └─── Program.cs
     ├───📂 AspireSample.AppHost
     │    └─── Program.cs
     ├───📂 AspireSample.ServiceDefaults
     │    └─── Extensions.cs
     ├───📂 AspireSample.Web
     │    ├───📂 Components
     │    │    ├───📂 Layout
     │    │    │    ....
     │    ├─── AspireSample.Web.csproj
     │    ├─── Program.cs
     │    └─── WeatherApiClient.cs
     └─── AspireSample.sln

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)

Common azd commands to deploy

// Install Azure Developer CLI
winget install microsoft.azd
//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

How azd up work ?

Official .NET Aspire Discord Channel

https://discord.com/invite/h87kDAHQgJ 

{DEMO}

  1. Create and run .NET Aspire project
  2. Explore .NET Aspire Dashboard
  3. Build and deploy .NET Aspire to Azure
  4. Add/Enable Application Insights to .NET Aspire Project
  5. Test .NET Aspire with other modern UI Frameworks
  6. Add .NET Aspire to existing app
Made with Slides.com