What is .NET Aspire.
.NET Aspire is an open-source, cloud-ready stack designed to streamline the development of observable, distributed applications. Introduced with .NET 8, it provides a unified toolchain of NuGet packages, project templates, and local orchestration tools to manage the complexities of cloud-native development.
Image source - Microsoft
Core Concepts
1. Orchestration
- .NET Aspire simplifies the management of frontends, APIs, containers, and databases.
- Unified Management: Provides tools and libraries to build and manage interconnected services.
- Seamless Integration: Easily add projects or services; the framework automatically handles container downloads and startup sequences.
- Service Discovery: Automatically manages communication between services by name, eliminating the need for hardcoded URLs.
2. Observability
- Gain deep insights into your application's health and performance without manual configuration.
- Aspire Dashboard: A real-time interface to view logs, telemetry, and service health.
- Traces & Metrics: Track service events and monitor critical data like active requests and duration.
- Console View: Monitor live output from each service to catch errors and debug instantly.
3. Integrations
- Easily connect to essential cloud-native services using curated NuGet packages (Components) for:
- Databases: SQL Server, PostgreSQL, MongoDB.
- Storage & Messaging: Azure Storage, RabbitMQ, Kafka. Caching: Redis.
Core Components of a .NET Aspire Solution
When you create a new .NET Aspire project, your solution typically includes these key projects:
AppHost
The central orchestrator. It manages project references, dependencies, and ensures all services run in the correct order locally.
Service Defaults
A shared project containing standard configurations for OpenTelemetry, health checks, and resilience patterns used across all services.
ApiService
A sample backend project (ASP.NET Core) pre-configured to interact with the Aspire ecosystem.
Web Frontend
The UI layer (e.g., Blazor or React) that is automatically integrated with the ApiService via the AppHost.
Local vs. Production Experience
Local Development
.NET Aspire utilizes Docker or Podman to spin up local containers for databases and caches. This ensures your development environment closely mirrors your production setup, reducing "it works on my machine" issues.
Cloud Deployment
Aspire simplifies the transition to the cloud by generating a JSON manifest file. This manifest can be consumed by deployment tools like the Azure Developer CLI (azd) to automatically provision and deploy infrastructure to platforms such as Azure Container Apps or Kubernetes.
Demo Code
Demo code available at https://github.com/dotnetmirror/Aspire-App-Demo
References
- https://youtu.be/REQnAK3LkKo
- https://github.com/dotnetmirror/Aspire-App-Demo