Guides .NET Aspire for cloud-native orchestration, service discovery, telemetry, and distributed component integration. Useful when building microservices or configuring cloud-native .NET apps.
Ships in claude-skills-collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
| Situation | Recommandation |
|---|---|
| ≥ 2 services qui se parlent en local | Aspire — service discovery automatique |
| Besoin de traces distribuées dès le dev | Aspire — dashboard OTEL intégré |
| Projet mono-service simple | Aspire superflu |
| Cible Azure Container Apps / Kubernetes | Aspire — manifeste généré via azd ou aspirate |
| Équipe < 3 devs, pas de messaging | À évaluer ; Aspire a un coût d'apprentissage |
Version stable 2026 : .NET Aspire 9.x (compatible .NET 8 et .NET 9).
# Prérequis : Docker Desktop actif, workload Aspire installé
dotnet workload install aspire
# Nouveau projet depuis le template
dotnet new aspire-starter -n MySolution -o MySolution
cd MySolution
# Structure générée
# MySolution.AppHost/ orchestrateur
# MySolution.ServiceDefaults/ config partagée
# MySolution.ApiService/ API demo
# MySolution.Web/ Blazor frontend
Pour ajouter Aspire à une solution existante :
dotnet new aspire-apphost -n MySolution.AppHost
dotnet new aspire-servicedefaults -n MySolution.ServiceDefaults
# Puis ajouter les références projets manuellement
L'AppHost est le point d'entrée unique. Il déclare les ressources (infra) et les projets (code), puis les relie.
// MySolution.AppHost/Program.cs
var builder = DistributedApplication.CreateBuilder(args);
// --- Infrastructure ---
var postgres = builder.AddPostgres("postgres")
.WithDataVolume("pgdata") // volume nommé = persistance entre runs
.WithPgAdmin(); // UI admin sur port aléatoire
var orderDb = postgres.AddDatabase("orderdb");
var redis = builder.AddRedis("cache").WithRedisCommander();
var bus = builder.AddRabbitMQ("messaging").WithManagementPlugin();
// --- Services applicatifs ---
var api = builder.AddProject<Projects.MySolution_ApiService>("api")
.WithReference(orderDb) // injecte la conn string via env var
.WithReference(redis)
.WithReference(bus)
.WithReplicas(2); // 2 instances en dev pour tester la LB
builder.AddProject<Projects.MySolution_Web>("web")
.WithExternalHttpEndpoints()
.WithReference(api); // URL résolue par service discovery
builder.Build().Run();
Règle : nommez les ressources en minuscules-tirets ("order-db"), ce nom devient la clé de service discovery.
Chaque service appelle AddServiceDefaults() dans son Program.cs. Ce package centralise : OpenTelemetry, health checks, resilience, service discovery.
// Dans chaque service : Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults(); // une seule ligne suffit
// MySolution.ServiceDefaults/Extensions.cs
public static IHostApplicationBuilder AddServiceDefaults(
this IHostApplicationBuilder builder)
{
builder.ConfigureOpenTelemetry();
builder.AddDefaultHealthChecks();
builder.Services.AddServiceDiscovery();
builder.Services.ConfigureHttpClientDefaults(http =>
{
http.AddStandardResilienceHandler(); // retry + circuit breaker
http.AddServiceDiscovery();
});
return builder;
}
public static IHostApplicationBuilder ConfigureOpenTelemetry(
this IHostApplicationBuilder builder)
{
builder.Logging.AddOpenTelemetry(o =>
{
o.IncludeFormattedMessage = true;
o.IncludeScopes = true;
});
builder.Services.AddOpenTelemetry()
.WithMetrics(m => m
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation())
.WithTracing(t => t
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddEntityFrameworkCoreInstrumentation());
builder.AddOpenTelemetryExporters(); // OTLP vers le dashboard Aspire
return builder;
}
// Résolution automatique du nom logique déclaré dans AppHost
builder.Services.AddHttpClient<IOrderServiceClient>(client =>
{
// "https+http://api" = nom donné dans AddProject("api")
// Aspire résout l'URL réelle (port dynamique) à l'exécution
client.BaseAddress = new Uri("https+http://api");
});
// Connexion PostgreSQL injectée automatiquement via Aspire
builder.AddNpgsqlDataSource("orderdb"); // "orderdb" = nom de la database dans AppHost
| Technologie | Package NuGet (AppHost) | Package NuGet (Service) | Méthode service |
|---|---|---|---|
| PostgreSQL | Aspire.Hosting.PostgreSQL | Aspire.Npgsql | AddNpgsqlDataSource |
| SQL Server | Aspire.Hosting.SqlServer | Aspire.Microsoft.Data.SqlClient | AddSqlServerClient |
| Redis | Aspire.Hosting.Redis | Aspire.StackExchange.Redis | AddRedisClient |
| RabbitMQ | Aspire.Hosting.RabbitMQ | Aspire.RabbitMQ.Client | AddRabbitMQClient |
| MongoDB | Aspire.Hosting.MongoDB | Aspire.MongoDB.Driver | AddMongoDBClient |
| Kafka | Aspire.Hosting.Kafka | Aspire.Confluent.Kafka | AddKafkaProducer |
| Azure Blob | Aspire.Hosting.Azure.Storage | Aspire.Azure.Storage.Blobs | AddAzureBlobClient |
| Azure Service Bus | Aspire.Hosting.Azure.ServiceBus | Aspire.Azure.Messaging.ServiceBus | AddAzureServiceBusClient |
| Elasticsearch | Aspire.Hosting.Elasticsearch | Aspire.Elastic.Clients.Elasticsearch | AddElasticsearchClient |
Lancé automatiquement avec dotnet run sur l'AppHost :
| Vue | Usage |
|---|---|
| Resources | État (Running/Stopped/Unhealthy) de chaque conteneur/projet |
| Console Logs | Stdout/stderr en temps réel, filtrable par service |
| Structured Logs | Logs JSON avec filtres sur niveau/message/attributs |
| Traces | Traces distribuées OTEL — waterfall inter-services |
| Metrics | Métriques runtime + applicatives (graphs) |
URL par défaut : https://localhost:17088 (token dans la console au démarrage).
dotnet tool install -g azd
azd init # détecte Aspire, génère azure.yaml
azd up # provision + deploy en une commande
dotnet tool install -g aspirate
aspirate init
aspirate generate # génère les manifests K8s
aspirate apply # kubectl apply automatique
// AppHost/Program.cs — switch dev/prod
if (builder.ExecutionContext.IsPublishMode)
{
// Azure SQL Managed Instance en prod
var sql = builder.AddAzureSqlServer("sql")
.AddDatabase("orderdb");
}
else
{
// SQL Server local en conteneur en dev
var sql = builder.AddSqlServer("sql")
.AddDatabase("orderdb");
}
| Problème | Cause | Correction |
|---|---|---|
| Service discovery échoue | Nom dans AddHttpClient ne correspond pas au nom AppHost | Utiliser exactement le même nom logique |
| Port déjà utilisé au démarrage | Aspire affecte des ports dynamiques mais les profils launchSettings peuvent fixer les ports | Supprimer les applicationUrl dans launchSettings.json des services |
| Données perdues entre redémarrages | Volume anonyme (sans .WithDataVolume("nom")) | Toujours nommer les volumes |
| Traces manquantes | AddServiceDefaults() non appelé dans un service | Vérifier que chaque service l'appelle |
| Container pull lent en CI | Images téléchargées à chaque run | Pré-pull les images dans le step CI ou utiliser un registry miroir |
WithReplicas en prod | Les réplicas Aspire sont pour le dev uniquement | En prod, déléguer le scaling à ACA/K8s |
| Secrets en clair dans AppHost | .WithEnvironment("API_KEY", "secret") visible dans les logs Aspire | Utiliser builder.AddParameter("api-key", secret: true) |
/health (liveness) et /alive (readiness) — Aspire les surveille.builder.AddParameter("conn", secret: true) + Azure Key Vault en prod.Aspire.Hosting.Testing pour démarrer l'AppHost dans xUnit.
// Test d'intégration avec DistributedApplicationTestingBuilder
await using var app = await DistributedApplicationTestingBuilder
.CreateAsync<Projects.MySolution_AppHost>();
await app.StartAsync();
var httpClient = app.CreateHttpClient("api");
var response = await httpClient.GetAsync("/health");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
.NET, C#, Docker, Kubernetes, RabbitMQ
/claude-skills-collection:dev-dotnet-aspire-guidefrom claude-skills-collection
npx claudepluginhub vantaflow/claude-skills-collection --plugin claude-skills-collection348 skills in this plugin
/agent-a2a-protocol-guideGuide du protocole Agent-to-Agent (A2A) de Google pour l'interopérabilité entre agents IA — découverte, communication et collaboration inter-agents, avec exemples de code, critères de décision et pièges à éviter. Se déclenche avec "A2A", "agent-to-agent", "protocole A2A", "Google A2A", "interopérabilité agents". Also triggers on "agent-to-agent protocol", "agent interoperability", "connect two agents"./agent-agent-observabilityInstrumentation technique d'un agent IA — tracing distribué des appels LLM et outils, spans, métriques custom, corrélation de logs et dashboards de supervision. Pour les alertes et garde-fous de production, voir agent-monitoring-setup. Se déclenche avec "observabilité agent", "tracing agent", "LangSmith", "Langfuse", "OpenTelemetry agent", "spans LLM", "corréler les logs agent". Also triggers on "trace my agent", "LLM tracing", "agent spans"./agent-api-caller-subagentSous-agent spécialisé dans les appels API REST/GraphQL avec retry, auth et transformation de données. Se déclenche avec "sous-agent API", "API caller agent", "agent qui appelle une API", "REST agent", "HTTP agent", "API integration subagent", "external API agent". Also triggers on "subagent that calls an API", "API calling agent", "agent HTTP requests".Other plugins' skills for the same job