.Net Aspire @ Junior Dev UG


Intro

I will be presenting at Junior Dev User group at 6th of August. My topic will be about .Net Aspire as I start talking about in my previous blog post. I will talk about how we used to leverage docker compose to containerise SQL, Redis and Queue from the following architecture and how .net aspire can help us bootstrap everything in one place with single source of truth.

Content of the Talk

  • how we were using docker compose and run multiple services with seperate terminals
  • how aspire can help us bootstrap the given architecture
  • what is aspire dashboard and what are the tabs
  • mentioned other integrations and examples (from Aspire Samples)
    • showing multiple service integration example (AspireShop)
    • using azure functions (ImageGallery)
    • showing angular, vue, react in apphost (AspireJavaScript)
    • using pyhton with aspire (AspireWithPython)
    • using wpf and windforms (ClientAppsIntegration)
    • using dockerfile in apphost (ContainerBuild)
    • database migrations and WorkerSdk (DatabaseMigrations)
    • containers in apphost (Metrics)
    • container data volume and lifetime (VolumeMount)

One thing I do not talk much about is the nuget packages comes with aspire, so I decided to use this space to talk about them.

đź”§ Aspire.Hosting.* Packages

These packages are part of the application orchestration layer of Aspire. They simplify configuring, running, and connecting services in a distributed app (often during development and testing). They don’t include SDKs or client libraries for calling services; instead, they help register services as resources for the orchestration host (AppHost) and set up development-time features like service discovery and environment variables.

PackageWhat it does
Aspire.Hosting.Azure.StorageRegisters Azure Storage resources (e.g., blob, queue, table) so Aspire can manage connection strings, secrets, service bindings, etc.
Aspire.Hosting.RedisDeclares a Redis container/service that your app can connect to.
Aspire.Hosting.SqlServerAdds a SQL Server resource to your app topology—used in orchestration, not data access itself.
Aspire.Hosting.NodeJsIntegrates a Node.js service (via project reference or executable) into Aspire’s orchestration.

📦 Aspire.* Wrapper Packages

These are higher-level packages that wrap existing .NET SDKs or libraries (like Azure.Storage.Queues or Microsoft.EntityFrameworkCore.SqlServer) and add Aspire-specific features like:

  • Auto-wiring of connection strings from AppHost
  • Diagnostic enrichment
  • Configuration via Aspire’s service discovery
  • Simplified DI registration
PackageWhat it does
Aspire.Hosting.Azure.StorageRegisters Azure Storage resources (e.g., blob, queue, table) so Aspire can manage connection strings, secrets, service bindings, etc.
Aspire.Hosting.RedisDeclares a Redis container/service that your app can connect to.
Aspire.Hosting.SqlServerAdds a SQL Server resource to your app topology—used in orchestration, not data access itself.
Aspire.Hosting.NodeJsIntegrates a Node.js service (via project reference or executable) into Aspire’s orchestration.

🆚 Aspire vs. Native NuGet Packages

  • Use Aspire.Hosting.* in your AppHost project to register and orchestrate services like Redis, SQL Server, Azure resources, etc.
  • Use Aspire.* wrapper packages in your application projects to auto-wire and configure service clients.
  • The wrappers simplify cloud-native development and reduce boilerplate, especially when using Aspire’s application model.
AspectAspire-native integration for cloud-native orchestrationGeneral-purpose .NET libraries for direct use
PurposeAspire-native integration for cloud-native orchestrationGeneral-purpose .NET libraries for direct use
SetupAutomatically configured via Aspire environmentManual configuration of endpoints, credentials
DIUsually adds DI extensionsOften manual setup or partial DI
Best forAspire-based appsStandalone apps or custom setups
// Using native
builder.Services.AddDbContext<AppDbContext>(options => {
    options.UseSqlServer(builder.Configuration.GetConnectionString("Sql"));
});

// Using Aspire
builder.AddSqlServerDbContext<AppDbContext>("appDb");

References: