Skip to main content

aspire add

Add a hosting integration to the AppHost.

Usage

aspire add [integration] [options]
aspire add [options]  # Interactive integration selection

Description

The aspire add command adds NuGet packages for Aspire hosting integrations to your AppHost project. Integrations provide pre-configured resources like databases, message queues, caching, and cloud services.

What it Does

  1. Searches for integrations - Queries NuGet feeds for available Aspire hosting packages
  2. Prompts for selection - Shows available integrations and versions
  3. Stops running instances - Automatically stops any running AppHost to avoid file locks
  4. Adds the package - Runs dotnet add package to install the integration
  5. Confirms success - Displays the installed package and version
After adding an integration, you’ll need to update your Program.cs to use it.

Arguments

integration
string
The name of the integration to add (e.g., redis, postgres, rabbitmq)Example: aspire add redisIf not specified, you’ll be prompted to select from available integrations.Supports fuzzy matching: aspire add pg will find PostgreSQL integrations.

Options

--apphost
string
The path to the Aspire AppHost project fileExample: --apphost ./src/MyApp.AppHost/MyApp.AppHost.csprojIf not specified, the CLI searches for an AppHost project in the current directory and parent directories.
--version
string
The version of the integration to addExample: --version 10.0.0If not specified, you’ll be prompted to select from available versions.
--source
string
The NuGet source to use for the integrationExample: --source https://api.nuget.org/v3/index.json

Examples

Add Redis

aspire add redis
Output:
✓ Searching for Aspire integrations...
✓ Adding Aspire hosting integration...
✓ The package Aspire.Hosting.Redis::10.0.0 was added successfully.
After adding, update your Program.cs:
var builder = DistributedApplication.CreateBuilder(args);

var redis = builder.AddRedis("cache");

var api = builder.AddProject<Projects.MyApi>("api")
    .WithReference(redis);

builder.Build().Run();

Add with interactive selection

aspire add
You’ll see a list of available integrations:
Select an integration to add:
  > redis (Aspire.Hosting.Redis)
    postgres (Aspire.Hosting.PostgreSQL)
    rabbitmq (Aspire.Hosting.RabbitMQ)
    sql-server (Aspire.Hosting.SqlServer)
    mongodb (Aspire.Hosting.MongoDB)
    ...

Add PostgreSQL

aspire add postgres
Then use it:
var postgres = builder.AddPostgres("postgres")
    .AddDatabase("mydb");

var api = builder.AddProject<Projects.MyApi>("api")
    .WithReference(postgres);
aspire add rabbit
This finds and selects Aspire.Hosting.RabbitMQ.

Add a specific version

aspire add redis --version 10.0.0-preview.1.25067.1

Add from a custom source

aspire add redis --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json

Available Integrations

Databases

  • postgres - PostgreSQL database (Aspire.Hosting.PostgreSQL)
  • sql-server - SQL Server database (Aspire.Hosting.SqlServer)
  • mysql - MySQL database (Aspire.Hosting.MySql)
  • mongodb - MongoDB database (Aspire.Hosting.MongoDB)
  • oracle - Oracle database (Aspire.Hosting.Oracle)

Caching & State

  • redis - Redis cache and pub/sub (Aspire.Hosting.Redis)
  • garnet - Garnet cache (Aspire.Hosting.Garnet)
  • valkey - Valkey cache (Aspire.Hosting.Valkey)

Messaging

  • rabbitmq - RabbitMQ message broker (Aspire.Hosting.RabbitMQ)
  • kafka - Apache Kafka (Aspire.Hosting.Kafka)
  • nats - NATS messaging (Aspire.Hosting.Nats)

Azure Services

  • azure-storage - Azure Storage (Blobs, Queues, Tables) (Aspire.Hosting.Azure.Storage)
  • azure-cosmos-db - Azure Cosmos DB (Aspire.Hosting.Azure.CosmosDB)
  • azure-service-bus - Azure Service Bus (Aspire.Hosting.Azure.ServiceBus)
  • azure-key-vault - Azure Key Vault (Aspire.Hosting.Azure.KeyVault)
  • azure-event-hubs - Azure Event Hubs (Aspire.Hosting.Azure.EventHubs)

Observability

  • seq - Seq structured logging (Aspire.Hosting.Seq)
  • elastic - Elasticsearch (Aspire.Hosting.Elasticsearch)

Other Services

  • milvus - Milvus vector database (Aspire.Hosting.Milvus)
  • qdrant - Qdrant vector database (Aspire.Hosting.Qdrant)
For a complete list, run aspire add and browse the interactive list.

Integration Naming

Package names are converted to friendly short names:
  • Aspire.Hosting.Redisredis
  • Aspire.Hosting.PostgreSQLpostgresql
  • Aspire.Hosting.Azure.Storageazure-storage
Both the friendly name and full package ID are accepted:
aspire add redis
aspire add Aspire.Hosting.Redis  # Same result

Version Selection

When multiple versions are available, you’ll be prompted:
Select a version of Aspire.Hosting.Redis:
  > 10.0.0 (nuget.org)
    10.0.0-preview.1.25067.1 (nuget.org)
    daily
  • Stable versions are listed first
  • Preview versions are shown with their full version numbers
  • Daily channel provides the latest daily builds

Channels

Integrations can come from different channels:
  • stable - Released versions from nuget.org
  • daily - Daily builds from dotnet-public feed
  • staging - Staging builds (when enabled)
Set a default channel:
aspire config set channel daily
aspire add redis  # Uses daily channel

Community Integrations

Community-contributed integrations are prioritized in the list for discoverability. These packages start with CommunityToolkit.Aspire.Hosting.*.

Running Instance Detection

Before adding a package, the CLI:
  1. Detects any running instances of your AppHost
  2. Stops them automatically to avoid file locks
  3. Displays a message confirming the stop
This prevents dotnet add package from failing due to locked project files.

After Adding an Integration

After running aspire add, you need to:
  1. Update Program.cs - Add the resource to your AppHost
  2. Add references - Wire up the integration to your services
  3. Run the AppHost - Test the integration
Example workflow:
aspire add redis
Edit Program.cs:
var builder = DistributedApplication.CreateBuilder(args);

var redis = builder.AddRedis("cache");

var api = builder.AddProject<Projects.MyApi>("api")
    .WithReference(redis);

builder.Build().Run();
Run:
aspire run

Removing Integrations

To remove an integration:
dotnet remove package Aspire.Hosting.Redis
And remove references from Program.cs.

See Also

Build docs developers (and LLMs) love