liveBook · Manning

Aspire integration library

As explained in Building Distributed Applications that Work

A reusable library that connects an application framework to an external service or infrastructure component.

An Aspire integration library connects an Aspire application to infrastructure such as a database, message broker, or distributed cache. It wraps a Docker-hosted component or a reference to a managed resource, providing extension methods that are easier to configure than a raw container. Most integrations use containers locally, but an integration need not run its resource in a container. section 2.5 section 2.8

An integration typically has two sides:

  • A hosting package lets the Aspire app host register, configure, and launch or reference the resource. section 3.2
  • A consumer package lets an application service interact with that resource. For SQL databases, client libraries support operations such as queries and updates, with or without Entity Framework. section 3.2

Start with Redis, then make an integration

For output caching, start with the Aspire Starter Project’s Redis option. The cache stores generated page output for subsequent requests, reducing repeated processing. After running the application, inspect the cache in the Aspire dashboard: a locally hosted Redis integration appears as a Container, and its Source path begins with docker.io. To start a custom integration around the MailDev Docker image, create a hosting class library with `dotnet new classlib -n OnlineShop.MailDev.Hosting`, then add it to the solution with `dotnet sln OnlineShop.sln add OnlineShop.MailDev.Hosting/OnlineShop.MailDev.Hosting.csproj`. Those commands create the project; it still needs integration code. section 2.5 section 2.6.2 section 2.7

Choose the resource’s hosting mode with its data in mind. A container is useful for local database development, but a persistent production database can instead be a managed instance. SQL integrations also work with Aspire service discovery, avoiding separately maintained connection strings in application configuration and deployment pipelines. section 2.5 section 3.2

Figure 2.8 Redis component shown in the Aspire dashboard
figure

The dashboard figure helps distinguish an integration library from the resource it hosts: the Redis integration is displayed as its underlying container. section 2.6.2

How Building Distributed Applications that Work covers it

How deep it goes
Distinguishes hosting and consumer packages, walks from a prebuilt Redis integration toward a custom MailDev library, and introduces its project setup.
Examples
Uses Redis output caching, a MailDev hosting-library project, and SQL Server integration as concrete cases.
What it assumes
Assumes familiarity with application services while introducing Docker containers before using them for Aspire infrastructure.
What you can do after
Build it from scratch as an Aspire hosting library, or apply a prebuilt integration to connect services to infrastructure.
How it connects
Links Docker containers, managed databases, service discovery, output caching, and Entity Framework to infrastructure integration.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Distributed Applications that Work. The section links point to the parts of the book it draws on.