.NET Aspire
Rainer Stropek | timecockpit
Rainer Stropek
Passionate software developer
IT-Entrepreneur, CoderDojo-Mentor, Teacher
software architects gmbh
rainer@software-architects.at
https://rainerstropek.me
What's The Problem?
Distributed Systems...
... are tedious to run on dev boxes 🤯
Browser (SPA)
Backend-for-Frontend (ASP.NET Core)
Backend (ASP.NET Core)
Backend (...)
Database (SQL)
...
Logging, Metrics
What is .NET Aspire?
- Tech stack to improve local development of distributed applications (aka cloud-native apps)
- Does not replace production systems like K8s
- Optional tooling for deployment to production (not focus of this talk)
- Focus on .NET
- NPM-based components are already supported, too
- Docker-based components
- Open, can be extended to support other tech stacks and clouds
- Makes heavy use of Docker
- Basic Docker knowledge is highly recommended
What is .NET Aspire?
- Orchestration
- Run and connect multi-project applications and dependencies
- Components
- Add commonly-used services like DBs, Redis, etc. (Docker-based)
- Tooling
- Visual Studio (Code)
- CLI
Status of .NET Aspire?
- Version 8 is production-ready, v9 is under development
- Stay away from it 😜
- Issues when .NET 9 Preview is installed
- Good documentation with lots of samples
 - Getting started:
https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/setup-tooling
Demo
Getting Started
- Create Aspire starter app
- Debug it
- Dashboard
- Structure
- App Host: Orchestrator project (startup)
- Service Defaults: Shared configurations
- Components: API, Frontend
- Create a new, empty Aspire app
- Project templates
![](https://s3.amazonaws.com/media-p.slid.es/uploads/507713/images/11398890/pasted-from-clipboard.png)
Add Web API ("WebApi")
- Enlist in Aspire during project creation
- Project reference to service defaults
- Add two endpoints (ping, customers)
- Adjust launch settings
Add Backend API ("MultiplierApi")
- Enlist in Aspire during project creation
- Project reference to service defaults
- Add endpoint
- Adjust launch settings
- Add new API to orchestrator project
- For demo: Two instances
Add SQL Server
- Dependency for Web API project
- Add SQL to code
- Add client to DI
- Add DB endpoint
- Adjust launch settings
- Show environment variables with connection string
- Call backend service with DB response
Add Frontend
- Add proxy configuration
- proxy.conf.js
- angular.json
- Provide HTTP client
- Add component with call to DB endpoint
 - Generate manifest
dotnet run --publisher manifest --output-path ../aspire-manifest.json
Aspire 🤘
Rainer Stropek | time cockpit
.NET Aspire Introduction
By Rainer Stropek
.NET Aspire Introduction
- 82