.NET Aspire

repository·main·Indexed 41 days ago

https://github.com/microsoft/aspire.dev

A cloud-ready application development framework designed to streamline the creation and orchestration of distributed applications. This documentation hub provides comprehensive guides, tutorials, API references, and an integration catalog featuring over 100 available Aspire integrations and packages.

Tokens
366.9K
Snippets
1.2K
Records
1.5K
Agent score
51%

What's inside Aspire

  1. Overview of Entity Framework Core integrations in Aspire

    main

    Aspire provides EF Core client integrations for popular relational and document databases. These integrations simplify the process of using EF Core in cloud-native microservices by automating several key tasks in your service's Program.cs:

    • Pooled DbContext registration: Automatically registers a context pool using Add<DatabaseSystem>DbContext to reduce per-request allocation overhead.
    • Observability: Enables health checks, OpenTelemetry distributed tracing, and connection-retry resiliency out of the box.
    • Centralized Connection Management: Database resources are declared in the AppHost and forwarded as named references to consuming services.

    Note: EF Core is a client integration. It runs inside your .NET microservices. The AppHost uses separate hosting integrations to manage the actual database containers or cloud resources.

  2. What is Aspire?

    main

    Aspire is a code-first orchestration and observability layer for distributed applications. It allows you to model services, frontends, databases, queues, caches, containers, and cloud dependencies in a single place.

    Key characteristics:

    • Code-first orchestration: Define your architecture in an AppHost using C# or TypeScript.
    • Multi-language support: Orchestrate workloads written in C#, JavaScript, Python, Go, Java, Rust, and more.
    • Unified Toolchain: Use the Aspire CLI to run applications, the Aspire Dashboard to observe logs and traces, and specialized tools to enable AI coding agents.
    • Environment Consistency: Use the same application model for local development and production deployment (e.g., to Kubernetes or cloud platforms).
  3. Overview of the Live status feature

    main

    The Live status feature provides real-time indicators for when the aspire.dev team is broadcasting on YouTube or Twitch. It consists of two main components:

    1. Header Icon: A strobing icon in the site header that indicates an active broadcast.
    2. Dynamic Routing: The /community/videos/ page automatically swaps its content to display the currently online stream, allowing visitors to watch immediately without manual navigation.
  4. Benefits of using Redis distributed caching integration

    main

    Using the Aspire integration instead of manual connection string management provides:

    • Drop-in IDistributedCache implementation: One line of code registers a functional implementation compatible with session state, data protection, and [OutputCache].
    • Automatic service registration: AddRedisDistributedCache registers IDistributedCache, the underlying IConnectionMultiplexer, and necessary plumbing.
    • Built-in health checks: Automatically verifies the Redis instance is reachable before the app is marked healthy.
    • OpenTelemetry support: Logging, distributed tracing, and metrics are automatically wired into the Aspire telemetry pipeline.
    • ASP.NET Core compatibility: Works transparently with higher-level abstractions like output caching and session state.
  5. Dashboard behavior improvements in Aspire 9.3

    main

    Several quality-of-life improvements have been added to the Aspire dashboard:

    • Filter Persistence: Resource filter settings (e.g., hiding support services) are now persisted in local storage, meaning they remain active across page refreshes and restarts.
    • Metrics Pause Warning: A warning banner appears on the metrics page when metrics collection is paused, indicating that data may be stale.
    • Friendly Names in Logs: For resources with only a single replica, the dashboard displays the friendly resource name (e.g., frontend) instead of the replica ID (e.g., frontend-0) in the console logs view to reduce visual noise. In multi-replica scenarios, full replica IDs are still used.
  6. Use the aspire docs api command group

    main

    The aspire docs api command group allows you to browse, search, and retrieve Aspire API reference material directly from aspire.dev. Unlike the standard aspire docs commands which handle prose documentation, these commands interact with an API reference index built from the aspire.dev sitemap. It supports both C# and TypeScript API hierarchies.

    Synopsis:

    aspire docs api [command] [options]
  7. Use the aspire agent command

    main

    The aspire agent command is used to manage AI agent integrations within Aspire. It provides functionality for initializing agent environment configurations, installing Aspire skills, and managing the Model Context Protocol (MCP) server. The MCP server allows AI assistants and development tools to interact with your Aspire AppHost to perform tasks like resource management, diagnostics, and observability.

    aspire agent [command] [options]
  8. Dashboard features in Aspire 9.1

    main

    The Aspire 9.1 dashboard includes several new capabilities for managing and viewing your application state:

    • Resource Relationships: Supports parent and child grouping (e.g., databases nested under a Postgres instance).
    • Localization: You can override the dashboard language independently of your browser settings via a language dropdown.
    • Telemetry Management: New buttons on the Console logs, Structured logs, Traces, and Metrics pages allow you to clear data. A "Remove all" button is available in the settings popup.
    • Filtering: Filter the Resource page by Resource type, State, and Health state.
    • Resource Details: The details pane now includes References, Back references, and Volumes (with mount types).
    • Console Log Enhancements: You can now download console logs for use in external diagnostic tools and toggle timestamps on or off.
    • UX Improvements: Resource commands (Start and Stop) are available directly on the Console logs page, and URLs within logs are now automatically clickable.
  9. Understand the TypeScript AppHost project structure

    main

    A TypeScript AppHost project is the orchestration layer for your application. When created via aspire new, it scaffolds a dedicated directory containing the entry point, configuration, and a generated SDK. If initialized in an existing project via aspire init --language typescript, Aspire creates a nested aspire-apphost/ package to keep the AppHost's toolchain and dependencies isolated from your existing application's package settings.

    Standard Structure:

    • apphost.mts: The main entry point where you define resources.
    • aspire.config.json: Central configuration for the AppHost.
    • .aspire/modules/: Automatically generated TypeScript SDK (do not edit).
    • package.json: Manages AppHost dependencies and scripts.
    • tsconfig.apphost.json: TypeScript configuration.
    - my-apphost/
      - .aspire/modules/  # Generated TypeScript SDK (do not edit)
      - apphost.mts       # Your AppHost entry point
      - aspire.config.json # Aspire configuration
      - package.json
      - tsconfig.apphost.json
  10. Access Aspire documentation and integrations

    main

    The aspire.dev website is the central hub for all Aspire-related resources. Use it to access:

    • Documentation: Comprehensive guides, tutorials, and API references.
    • Integration Catalog: A showcase of over 100 available Aspire integrations and packages.
    • Getting Started: Onboarding resources for new developers.
    • Marketing: Information regarding features, benefits, and use cases.
  11. What is the AppHost?

    main

    The AppHost is the orchestration project where you define your entire application's architecture. It acts as the 'control tower' for your distributed application by:

    • Declaring services, databases, and containers.
    • Defining resource dependencies.
    • Configuring resource communication.
    • Orchestrating startup order during local development.
    • Generating deployment artifacts for production.

    In C#, the AppHost is typically the Program.cs file in your AppHost project. In TypeScript, it is the entry point using createBuilder.

    // C# AppHost example
    var builder = DistributedApplication.CreateBuilder(args);
    
    var db = builder.AddPostgres("db");
    var api = builder.AddProject<Projects.Api>("api")
        .WithReference(db);
    
    builder.Build().Run();