.NET Aspire — Nền tảng Cloud-Native giúp .NET Developer không còn sợ Microservices

Posted on: 4/20/2026 9:10:06 PM

Nếu bạn đã từng mất cả buổi sáng chỉ để chạy được 5 services trên máy local — cấu hình connection string, chỉnh port, debug xem service nào chưa start — thì .NET Aspire sinh ra để giải quyết chính xác nỗi đau đó. Đây là nền tảng cloud-native orchestration của Microsoft, biến việc phát triển ứng dụng phân tán từ "cơn ác mộng" thành trải nghiệm mượt mà chỉ với vài dòng C#. Bài viết này đi sâu từ kiến trúc, cách hoạt động, đến thực hành triển khai với phiên bản mới nhất Aspire 13 trên .NET 10.

1. .NET Aspire là gì và tại sao cần nó?

.NET Aspire là một bộ công cụ (stack) giúp xây dựng ứng dụng cloud-native, observable và production-ready. Không giống một framework bắt bạn viết lại code, Aspire là một lớp orchestration bao bọc bên ngoài các project hiện có, cung cấp 3 trụ cột chính:

13.0 Phiên bản GA mới nhất (2026)
100+ Integration components chính thức
40% Giảm chi phí hạ tầng (theo benchmark 2026)
0 config Service discovery tự động — không hardcode IP/port

Aspire không phải framework mới

Aspire không thay thế ASP.NET Core, Entity Framework hay bất kỳ thư viện nào bạn đang dùng. Nó là một lớp điều phối (orchestration layer) giúp bạn kết nối, cấu hình và giám sát các service đã có. Bạn có thể thêm Aspire vào project hiện tại mà không cần viết lại bất cứ thứ gì.

1.1. Ba trụ cột của .NET Aspire

graph TB
    ASPIRE["🏗️ .NET Aspire"] --> ORCH["Orchestration
(AppHost)"] ASPIRE --> COMP["Integration
Components"] ASPIRE --> TOOL["Tooling
(Dashboard + CLI)"] ORCH --> SD["Service Discovery"] ORCH --> ENV["Environment Config"] ORCH --> LIFE["Lifecycle Management"] COMP --> REDIS["Redis"] COMP --> PG["PostgreSQL"] COMP --> RMQ["RabbitMQ"] COMP --> MORE["100+ khác..."] TOOL --> DASH["Dashboard
Logs / Traces / Metrics"] TOOL --> CLI["aspire CLI
publish / deploy"] style ASPIRE fill:#e94560,stroke:#fff,color:#fff style ORCH fill:#2c3e50,stroke:#e94560,color:#fff style COMP fill:#2c3e50,stroke:#e94560,color:#fff style TOOL fill:#2c3e50,stroke:#e94560,color:#fff style SD fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style ENV fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style LIFE fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style REDIS fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style PG fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style RMQ fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style MORE fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style DASH fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50 style CLI fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50

Hình 1: Ba trụ cột chính của .NET Aspire — Orchestration, Components và Tooling

  • Orchestration (AppHost): Dùng C# thuần để khai báo toàn bộ infrastructure — database, cache, message broker, API service — trong một file Program.cs duy nhất. Không YAML, không JSON config phức tạp.
  • Integration Components: Thư viện NuGet đã cấu hình sẵn health check, retry, telemetry, connection pooling. Thêm Redis chỉ cần builder.AddRedisClient("cache").
  • Tooling: Dashboard web để xem logs, distributed traces, metrics real-time. CLI aspire hỗ trợ publish ra Docker Compose, Kubernetes manifests, Azure Bicep.

2. AppHost — Trái tim Orchestration bằng C#

Mọi thứ trong Aspire bắt đầu từ project AppHost — một console app đặc biệt đóng vai trò "conductor" cho toàn bộ hệ thống. Thay vì viết docker-compose.yml dài dằng dặc, bạn khai báo infrastructure bằng C# type-safe:

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

// Infrastructure resources
var cache = builder.AddRedis("cache");
var postgres = builder.AddPostgres("pg")
    .AddDatabase("catalogdb");
var rabbitmq = builder.AddRabbitMQ("messaging");

// Application services
var catalogApi = builder.AddProject<Projects.CatalogApi>("catalog-api")
    .WithReference(postgres)
    .WithReference(cache);

var orderApi = builder.AddProject<Projects.OrderApi>("order-api")
    .WithReference(rabbitmq)
    .WithReference(catalogApi);  // service-to-service reference

var webFrontend = builder.AddProject<Projects.WebApp>("webapp")
    .WithExternalHttpEndpoints()
    .WithReference(catalogApi)
    .WithReference(orderApi);

builder.Build().Run();

Type-safe > YAML

Khác với Docker Compose (YAML) hay Kubernetes (YAML), AppHost dùng C# nên bạn có IntelliSense, compile-time check, refactoring. Đổi tên service? Compiler báo lỗi ngay ở mọi chỗ reference. Với YAML, bạn chỉ biết lỗi khi runtime.

2.1. WithReference() và Service Discovery tự động

Khi bạn gọi .WithReference(catalogApi), Aspire tự động:

  1. Inject environment variable chứa endpoint của catalog-api vào order-api
  2. Đăng ký service discovery để order-api gọi catalog-api qua URI scheme đặc biệt: https+http://catalog-api
  3. Aspire runtime resolve URI này thành địa chỉ thực tại thời điểm chạy
// Trong OrderApi — gọi CatalogApi qua service discovery
builder.Services.AddHttpClient<CatalogClient>(client =>
{
    // Aspire tự resolve "https+http://catalog-api" → http://localhost:5123 (local)
    // hoặc → http://catalog-api.ns.svc.cluster.local (Kubernetes)
    client.BaseAddress = new Uri("https+http://catalog-api");
});
sequenceDiagram
    participant AppHost as AppHost (Orchestrator)
    participant OrderApi as Order API
    participant DNS as Service Discovery
    participant CatalogApi as Catalog API

    AppHost->>OrderApi: Inject env: services__catalog-api__https__0
    AppHost->>CatalogApi: Start on dynamic port
    OrderApi->>DNS: Resolve "https+http://catalog-api"
    DNS-->>OrderApi: http://localhost:5123
    OrderApi->>CatalogApi: GET /api/products
    CatalogApi-->>OrderApi: 200 OK [products]

Hình 2: Service Discovery flow — AppHost inject config, runtime resolve tự động

Điểm hay nhất: code trong OrderApi không thay đổi gì khi chuyển từ local → Docker → Kubernetes. URI https+http://catalog-api hoạt động ở mọi môi trường vì Aspire inject đúng giá trị cho từng context.

3. Integration Components — Plug-and-Play hạ tầng

Aspire cung cấp hơn 100 integration components dưới dạng NuGet package. Mỗi component đã được cấu hình sẵn với:

  • Health checks: Tự đăng ký endpoint /health kiểm tra kết nối
  • Resilience: Retry, circuit breaker, timeout qua Microsoft.Extensions.Resilience
  • Telemetry: OpenTelemetry traces + metrics tự động
  • Connection pooling: Quản lý pool tối ưu cho từng loại resource
ComponentNuGet Package (Hosting)NuGet Package (Client)Chức năng
RedisAspire.Hosting.RedisAspire.StackExchange.RedisCache, pub/sub, distributed lock
PostgreSQLAspire.Hosting.PostgreSQLAspire.Npgsql.EntityFrameworkCoreDatabase với EF Core integration
RabbitMQAspire.Hosting.RabbitMQAspire.RabbitMQ.ClientMessage broker, queue, exchange
SQL ServerAspire.Hosting.SqlServerAspire.Microsoft.Data.SqlClientSQL Server + EF Core
MongoDBAspire.Hosting.MongoDBAspire.MongoDB.DriverDocument database
KafkaAspire.Hosting.KafkaAspire.Confluent.KafkaEvent streaming platform
Azure BlobAspire.Hosting.Azure.StorageAspire.Azure.Storage.BlobsObject storage
ElasticsearchAspire.Hosting.ElasticsearchAspire.Elastic.Clients.ElasticsearchFull-text search

3.1. Hai loại package: Hosting vs Client

Mỗi integration có 2 NuGet riêng biệt:

  • Hosting package (cài vào AppHost): Khai báo resource — ví dụ builder.AddRedis("cache") sẽ tự tải Redis container image, cấu hình port, tạo health check.
  • Client package (cài vào service project): Đăng ký client — ví dụ builder.AddRedisClient("cache") inject IConnectionMultiplexer đã cấu hình sẵn retry + telemetry.
// Trong service project (CatalogApi)
var builder = WebApplication.CreateBuilder(args);

// Một dòng duy nhất — tự kết nối Redis với connection string từ Aspire
builder.AddRedisClient("cache");

// Hoặc với Entity Framework Core + PostgreSQL
builder.AddNpgsqlDbContext<CatalogDbContext>("catalogdb");

var app = builder.Build();

Không cần connection string trong appsettings.json

Aspire inject connection string qua environment variable. Khi chạy local, AppHost tự tạo container Redis/PostgreSQL và truyền connection string tương ứng. Khi deploy lên cloud, bạn chỉ cần thay bằng managed service (Azure Cache for Redis, Amazon RDS) — code không đổi.

4. Aspire Dashboard — Observability không cần Grafana

Một trong những điểm mạnh nhất của Aspire là dashboard tích hợp sẵn. Khi chạy AppHost (dotnet run), dashboard tự mở trên browser, hiển thị:

graph LR
    DASH["Aspire Dashboard"] --> RES["Resources
Trạng thái service"] DASH --> LOG["Structured Logs
Filter theo service/level"] DASH --> TRACE["Distributed Traces
Request flow qua services"] DASH --> METRIC["Metrics
CPU, Memory, Request rate"] DASH --> CONSOLE["Console Output
Stdout/stderr real-time"] RES --> HEALTH["Health status"] RES --> ENDPOINT["Endpoints & ports"] RES --> RELATION["Quan hệ giữa resources"] style DASH fill:#e94560,stroke:#fff,color:#fff style RES fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style LOG fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style TRACE fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style METRIC fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style CONSOLE fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style HEALTH fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50 style ENDPOINT fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50 style RELATION fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50

Hình 3: Aspire Dashboard — 5 tab chính cho observability toàn diện

4.1. Distributed Traces — Theo dõi request xuyên suốt hệ thống

Khi một request từ frontend đi qua API Gateway → Order API → Catalog API → PostgreSQL → Redis, dashboard hiển thị toàn bộ trace chain dưới dạng waterfall view. Bạn thấy ngay service nào chậm, query nào tốn thời gian, cache hit hay miss.

Tất cả được tích hợp sẵn nhờ OpenTelemetry — bạn không cần cấu hình gì thêm. Aspire tự thêm instrumentation cho HTTP, database, messaging khi bạn dùng integration components.

4.2. Dùng Dashboard ngoài Aspire

Aspire Dashboard có thể chạy độc lập (standalone container) cho các project không dùng Aspire. Chỉ cần trỏ OTLP exporter về nó:

# Chạy standalone dashboard
docker run -d --name aspire-dashboard \
  -p 18888:18888 \
  -p 18889:18889 \
  mcr.microsoft.com/dotnet/aspire-dashboard:latest

# Trỏ OTLP exporter từ bất kỳ app nào
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:18889

Dashboard miễn phí, production-ready

Aspire Dashboard hoàn toàn miễn phí và có thể thay thế Grafana + Jaeger + Kibana cho team nhỏ. Với team lớn hơn, bạn vẫn export telemetry về Grafana/Datadog — OpenTelemetry cho phép gửi đến nhiều backend cùng lúc.

5. Aspire vs Docker Compose vs Kubernetes — Khi nào dùng gì?

Câu hỏi thường gặp nhất: "Aspire thay thế Docker Compose à?" Câu trả lời là Aspire bổ sung, không thay thế. Aspire orchestrate ở tầng development và có thể sinh ra Docker Compose hoặc Kubernetes manifests.

Tiêu chí.NET AspireDocker ComposeKubernetes
Ngôn ngữ cấu hìnhC# (type-safe, IntelliSense)YAMLYAML + Helm templates
Service DiscoveryTự động (URI scheme)DNS nội bộ (service name)DNS + Service resource
ObservabilityDashboard tích hợp sẵnTự cài (Grafana, Jaeger...)Tự cài hoặc managed
Health CheckTự đăng ký khi dùng componentPhải viết trong DockerfileLiveness + Readiness probe
ResilienceRetry/circuit breaker tích hợpKhông cóIstio/Linkerd (service mesh)
Deployment targetLocal / Docker / K8s / AzureDocker hostK8s cluster
Learning curveThấp (nếu biết .NET)Trung bìnhCao
Production-readyCần publish ra K8s/AzureCó (cho scale nhỏ-vừa)Có (scale lớn)
graph LR
    DEV["Development
(Aspire AppHost)"] -->|"aspire publish"| COMPOSE["Docker Compose
(Staging)"] DEV -->|"aspire publish"| K8S["Kubernetes
(Production)"] DEV -->|"aspire publish"| AZURE["Azure Container Apps
(Managed)"] DEV -->|"aspire publish"| BICEP["Azure Bicep
(IaC)"] style DEV fill:#e94560,stroke:#fff,color:#fff style COMPOSE fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style K8S fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style AZURE fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style BICEP fill:#f8f9fa,stroke:#e94560,color:#2c3e50

Hình 4: Aspire publish — từ development sang nhiều deployment target khác nhau

6. Aspire 13 — Những cập nhật đáng chú ý nhất

Phiên bản Aspire 13 (GA cùng .NET 10 LTS vào tháng 11/2025, cập nhật liên tục đến 2026) mang đến nhiều cải tiến quan trọng:

Aspire 9.0 — 11/2024
Phiên bản đầu tiên ổn định. Dashboard, service discovery, 50+ integrations. Giới thiệu WaitFor() để quản lý startup order.
Aspire 9.1 — 01/2025
GitHub Codespaces + Dev Container support. Visual resource relationship nesting trên dashboard. CORS support cho dashboard.
Aspire 9.4 — 08/2025
aspire publishaspire deploy GA. External service resources. AI integration components (Azure OpenAI, Ollama).
Aspire 13.0 — 11/2025
Rebranded thành "Aspire" (bỏ prefix .NET). aspire do pipeline. Polyglot orchestration (Python, Node.js, Java). 100+ integrations.
Aspire 13.x — 2026
Cải tiến liên tục: better startup performance, enhanced dashboard filtering, improved publish targets cho AWS ECS và GCP Cloud Run.

6.1. aspire do — Pipeline linh hoạt

aspire do là tính năng mới cho phép định nghĩa pipeline build → publish → deploy có thể chạy song song, thay vì tuần tự từng bước:

# Build, publish và deploy trong một lệnh
aspire do --pipeline build,publish,deploy --target azure

# Chỉ publish ra Docker Compose
aspire do --pipeline publish --publisher docker-compose

# Publish ra Kubernetes manifests
aspire do --pipeline publish --publisher kubernetes

6.2. Polyglot Orchestration — Không chỉ .NET

Aspire 13 hỗ trợ orchestrate cả service viết bằng Python, Node.js hay Java. Điều này đặc biệt hữu ích cho team có microservices đa ngôn ngữ:

var builder = DistributedApplication.CreateBuilder(args);

// .NET service
var api = builder.AddProject<Projects.MainApi>("main-api");

// Python ML service
var mlService = builder.AddPythonApp("ml-service", "../ml-service", "main.py")
    .WithHttpEndpoint(targetPort: 8000);

// Node.js frontend
var frontend = builder.AddNodeApp("frontend", "../frontend", "server.js")
    .WithReference(api)
    .WithExternalHttpEndpoints();

builder.Build().Run();

Polyglot có giới hạn

Với service non-.NET, bạn không có integration components (health check, retry, telemetry tự động). Bạn cần tự cấu hình OpenTelemetry trong Python/Node.js service. Aspire chỉ quản lý lifecycle (start/stop) và service discovery cho chúng.

7. Thực hành: Xây dựng hệ thống E-commerce với Aspire

Để hiểu rõ cách Aspire hoạt động, hãy xây dựng một hệ thống e-commerce đơn giản gồm 4 service:

graph TB
    USER["👤 User"] --> WEB["Web Frontend
(Blazor / Vue.js)"] WEB --> CATAPI["Catalog API
(.NET 10)"] WEB --> ORDAPI["Order API
(.NET 10)"] CATAPI --> PG["PostgreSQL
(catalogdb)"] CATAPI --> REDIS["Redis Cache"] ORDAPI --> SQL["SQL Server
(orderdb)"] ORDAPI --> RMQ["RabbitMQ"] RMQ --> NOTIFY["Notification Worker
(.NET Background Service)"] style USER fill:#f8f9fa,stroke:#e94560,color:#2c3e50 style WEB fill:#e94560,stroke:#fff,color:#fff style CATAPI fill:#2c3e50,stroke:#e94560,color:#fff style ORDAPI fill:#2c3e50,stroke:#e94560,color:#fff style PG fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50 style REDIS fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50 style SQL fill:#f8f9fa,stroke:#4CAF50,color:#2c3e50 style RMQ fill:#f8f9fa,stroke:#ff9800,color:#2c3e50 style NOTIFY fill:#16213e,stroke:#e94560,color:#fff

Hình 5: Kiến trúc E-commerce mẫu với Aspire orchestration

7.1. Tạo solution structure

# Tạo solution với Aspire template
dotnet new aspire-starter -n EShop
cd EShop

# Solution structure được tạo tự động:
# EShop.AppHost/          ← Orchestrator
# EShop.ServiceDefaults/  ← Shared config (telemetry, health check, resilience)
# EShop.Web/              ← Frontend
# EShop.ApiService/       ← API mẫu

# Thêm service mới
dotnet new webapi -n EShop.CatalogApi -o EShop.CatalogApi
dotnet new webapi -n EShop.OrderApi -o EShop.OrderApi
dotnet new worker -n EShop.NotificationWorker -o EShop.NotificationWorker
dotnet sln add EShop.CatalogApi EShop.OrderApi EShop.NotificationWorker

7.2. Cấu hình AppHost

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

// --- Infrastructure ---
var redis = builder.AddRedis("cache")
    .WithDataVolume("redis-data");  // persist data qua restart

var postgres = builder.AddPostgres("pg")
    .WithDataVolume("pg-data")
    .WithPgAdmin()                  // tự chạy pgAdmin UI
    .AddDatabase("catalogdb");

var sqlserver = builder.AddSqlServer("sql")
    .WithDataVolume("sql-data")
    .AddDatabase("orderdb");

var rabbitmq = builder.AddRabbitMQ("messaging")
    .WithManagementPlugin();        // RabbitMQ Management UI

// --- Application Services ---
var catalogApi = builder.AddProject<Projects.EShop_CatalogApi>("catalog-api")
    .WithReference(postgres)
    .WithReference(redis)
    .WaitFor(postgres)              // chờ postgres healthy trước khi start
    .WaitFor(redis);

var orderApi = builder.AddProject<Projects.EShop_OrderApi>("order-api")
    .WithReference(sqlserver)
    .WithReference(rabbitmq)
    .WithReference(catalogApi)      // gọi catalog-api qua service discovery
    .WaitFor(sqlserver)
    .WaitFor(rabbitmq);

var notifyWorker = builder.AddProject<Projects.EShop_NotificationWorker>("notify-worker")
    .WithReference(rabbitmq)
    .WaitFor(rabbitmq);

builder.AddProject<Projects.EShop_Web>("webapp")
    .WithExternalHttpEndpoints()
    .WithReference(catalogApi)
    .WithReference(orderApi);

builder.Build().Run();

7.3. ServiceDefaults — Cấu hình dùng chung

Project ServiceDefaults chứa extension method áp dụng cho mọi service trong hệ thống:

// EShop.ServiceDefaults/Extensions.cs
public static IHostApplicationBuilder AddServiceDefaults(
    this IHostApplicationBuilder builder)
{
    // OpenTelemetry: traces + metrics + logs
    builder.ConfigureOpenTelemetry();

    // Health check endpoints: /health, /alive
    builder.AddDefaultHealthChecks();

    // Service discovery
    builder.Services.AddServiceDiscovery();

    // Resilience: retry + circuit breaker cho mọi HttpClient
    builder.Services.ConfigureHttpClientDefaults(http =>
    {
        http.AddStandardResilienceHandler();
        http.AddServiceDiscovery();
    });

    return builder;
}

Mỗi service chỉ cần gọi một dòng builder.AddServiceDefaults() để có đầy đủ telemetry, health check và resilience.

8. Deployment — Từ Local đến Production

Aspire không chỉ dùng cho development. Từ phiên bản 9.4 trở đi, aspire publish hỗ trợ sinh ra deployment artifacts cho nhiều target:

PublisherOutputPhù hợp khi
docker-composedocker-compose.yml + .envStaging, team nhỏ, VPS đơn
kubernetesDeployment, Service, ConfigMap YAMLProduction scale, team có K8s
azureBicep templates cho Azure Container AppsAzure ecosystem
helmHelm chartK8s với Helm workflow
# Sinh Docker Compose cho staging
aspire publish --publisher docker-compose --output-path ./deploy/staging

# Sinh Kubernetes manifests
aspire publish --publisher kubernetes --output-path ./deploy/k8s

# Deploy trực tiếp lên Azure Container Apps
aspire deploy --publisher azure --subscription <sub-id>

Manifest generation, không phải magic

aspire publish sinh ra file cấu hình chuẩn (YAML, Bicep) mà bạn có thể review, chỉnh sửa và commit vào git. Nó không phải "one-click deploy" — bạn vẫn kiểm soát hoàn toàn pipeline CI/CD.

9. WaitFor() và Lifecycle Management

Một vấn đề kinh điển với microservices: service A start trước database → crash → restart loop. Aspire giải quyết bằng WaitFor():

// Order API sẽ KHÔNG start cho đến khi SQL Server healthy
var orderApi = builder.AddProject<Projects.OrderApi>("order-api")
    .WaitFor(sqlserver)       // chờ SQL Server sẵn sàng
    .WaitFor(rabbitmq);       // chờ RabbitMQ sẵn sàng

// Hoặc chờ theo completion (cho job/migration)
var migration = builder.AddProject<Projects.DbMigration>("db-migration")
    .WaitFor(postgres);

var api = builder.AddProject<Projects.MainApi>("main-api")
    .WaitForCompletion(migration)  // chờ migration XONG mới start
    .WaitFor(postgres);

WaitFor() dùng health check để xác định resource đã ready chưa. WaitForCompletion() chờ process exit thành công — phù hợp cho database migration, seed data.

10. Best Practices khi dùng Aspire

10 quy tắc vàng

  1. Luôn dùng ServiceDefaults: Mọi service phải gọi AddServiceDefaults() để đảm bảo telemetry và health check đồng nhất.
  2. WaitFor() cho mọi dependency: Không để service start khi infrastructure chưa ready.
  3. WithDataVolume() cho stateful resources: Redis, PostgreSQL cần persist data qua restart khi develop local.
  4. Tách AppHost khỏi business logic: AppHost chỉ chứa khai báo infrastructure, không chứa code nghiệp vụ.
  5. Dùng parameters cho secrets: builder.AddParameter("db-password", secret: true) thay vì hardcode.
  6. Tận dụng WithReplicas(): Test scaling local với .WithReplicas(3) trước khi deploy production.
  7. Export telemetry cho production: Dashboard phù hợp dev/staging, nhưng production nên export về Grafana/Datadog.
  8. Review generated manifests: Luôn kiểm tra output của aspire publish trước khi apply.
  9. Sử dụng Custom Resource: Tạo resource type riêng cho infrastructure đặc thù thay vì dùng AddContainer() trực tiếp.
  10. CI/CD với aspire do: Tích hợp aspire do --pipeline build,publish vào GitHub Actions / Azure Pipelines.

11. Kết luận

.NET Aspire giải quyết một bài toán mà developer phân tán đã đau đầu hàng thập kỷ: làm sao để phát triển, debug và triển khai hệ thống nhiều service một cách đơn giản. Thay vì viết hàng trăm dòng YAML và cấu hình thủ công, bạn khai báo hệ thống bằng C# type-safe, có IntelliSense, compile-time check và dashboard observability tích hợp.

Với Aspire 13 hỗ trợ polyglot orchestration, aspire do pipeline và hơn 100 integrations, đây không còn là thí nghiệm — mà là công cụ production-ready cho mọi team .NET muốn chuyển sang kiến trúc microservices hoặc modular monolith mà không muốn chìm trong infrastructure complexity.

Nguồn tham khảo: