dotnet-aspire

v2026.09.25

.NET Aspire for cloud-native app orchestration, service discovery, telemetry, and component integrations

GitHub
安装命令
npx skhub add thelobbi/dotnet-aspire
Markdown
SKILL.md

.NET Aspire

What is Aspire?

.NET Aspire is an opinionated, cloud-ready stack for building observable, production-ready, distributed applications. It provides:

  • Orchestration - Coordinate multi-service apps with AppHost
  • Components - Pre-configured NuGet packages for common services (Redis, PostgreSQL, RabbitMQ, etc.)
  • Tooling - Dashboard for logs, traces, metrics; CLI for management
  • Service Defaults - Shared configuration for health checks, telemetry, resilience

AppHost (Orchestrator)

// MyApp.AppHost/Program.cs
var builder = DistributedApplication.CreateBuilder(args);

// Infrastructure resources
var postgres = builder.AddPostgres("postgres").WithDataVolume().WithPgAdmin();
var redis = builder.AddRedis("redis").WithRedisInsight();
var rabbitmq = builder.AddRabbitMQ("messaging").WithManagementPlugin();

// Databases
var appDb = postgres.AddDatabase("appdb");

// Projects (services)
var api = builder.AddProject<Projects.Api>("api")
    .WithReference(appDb)
    .WithReference(redis)
    .WithReference(rabbitmq)
    .WithExternalHttpEndpoints();

var web = builder.AddProject<Projects.Web>("web")
    .WithReference(api)
    .WithReference(redis)
    .WithExternalHttpEndpoints();

var worker = builder.AddProject<Projects.Worker>("worker")
    .WithReference(rabbitmq)
    .WithReference(appDb);

builder.Build().Run();

Service Defaults

// ServiceDefaults/Extensions.cs (shared project)
public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
{
    builder.ConfigureOpenTelemetry();
    builder.AddDefaultHealthChecks();
    builder.Services.AddServiceDiscovery();

    builder.Services.ConfigureHttpClientDefaults(http =>
    {
        http.AddStandardResilienceHandler();
        http.AddServiceDiscovery();
    });

    return builder;
}

Component Integrations

ComponentNuGet PackageAddXxx Method
PostgreSQL (EF)Aspire.Npgsql.EntityFrameworkCore.PostgreSQLAddNpgsqlDbContext<T>()
SQL Server (EF)Aspire.Microsoft.EntityFrameworkCore.SqlServerAddSqlServerDbContext<T>()
Redis CacheAspire.StackExchange.Redis.DistributedCachingAddRedisDistributedCache()
Redis Output CacheAspire.StackExchange.Redis.OutputCachingAddRedisOutputCache()
RabbitMQAspire.RabbitMQ.ClientAddRabbitMQClient()
Azure Service BusAspire.Azure.Messaging.ServiceBusAddAzureServiceBusClient()
Azure Blob StorageAspire.Azure.Storage.BlobsAddAzureBlobClient()
Cosmos DBAspire.Microsoft.Azure.CosmosAddAzureCosmosClient()

Dashboard

The Aspire dashboard provides:

  • Structured logs from all services
  • Distributed traces across service boundaries
  • Metrics (request rates, latencies, error rates)
  • Resource status and health checks

Access at: https://localhost:18888 (default)

Deployment

# Deploy to Azure Container Apps
azd init
azd provision  # Creates Azure resources
azd deploy     # Deploys all services

# Or use Aspire CLI
aspire publish --publisher azure

Key Patterns

  • Every service project calls builder.AddServiceDefaults()
  • Use WithReference() to establish service dependencies
  • Use WithExternalHttpEndpoints() for publicly accessible services
  • Service discovery uses https+http://service-name URIs
  • All telemetry is automatically correlated across services
发现
标签

此技能尚未发布标签。

版本
最新版本元数据

版本

v2026.09.25

发布时间

2026年9月25日

分类

未分类

许可证

MIT

源路径

plugins/dotnet-blazor/skills/dotnet-aspire

默认分支

main

最新提交

2f1269c

Tree SHA

629e050