IDistributedApplicationBuilder for adding resources to your application. These methods follow a consistent pattern and return IResourceBuilder<T> for fluent configuration.
Pattern Overview
All resource extension methods follow this pattern:- Returns
IResourceBuilder<TResource>for method chaining nameparameter must be unique within the application- Names are case-insensitive
Container Resources
AddContainer
Adds a generic Docker container.Unique name for the container resource.
Container image name (without tag).
Container image tag.
AddDockerfile
Builds a container from a Dockerfile.Unique name for the container resource.
Build context path (relative to app host or absolute).
Path to Dockerfile relative to context path.
Target stage in multi-stage Dockerfile.
.NET Project Resources
AddProject
Adds a .NET project to the application.Type from the project’s generated metadata (e.g.,
Projects.Api).Unique name for the project resource.
Name of the launch profile to use from launchSettings.json.
The
Projects class is generated by the Aspire SDK based on project references in your app host.Executable Resources
AddExecutable
Runs an arbitrary executable program.Unique name for the executable resource.
Command or path to executable.
Working directory for the executable.
AddNpmApp
Runs a Node.js application using npm.Unique name for the npm app resource.
Directory containing package.json.
npm script to run from package.json.
Database Resources
SQL Server
Adds a SQL Server container.Parameters:
name- Resource nameport- Optional external port
Adds a database to the SQL Server instance.Parameters:
name- Database name (also used as resource name)
PostgreSQL
Adds a PostgreSQL container.Parameters:
name- Resource nameport- Optional external portpassword- Optional password parameter
Adds a database to the PostgreSQL instance.
Redis
Adds a Redis container.Parameters:
name- Resource nameport- Optional external port
MongoDB
Adds a MongoDB container.
Adds a database to the MongoDB instance.
Message Queue Resources
RabbitMQ
Adds a RabbitMQ container with AMQP endpoint.Parameters:
name- Resource nameport- Optional external port for AMQP
Kafka
Adds a Kafka container with KRaft mode (no ZooKeeper).
Parameter Resources
AddParameter
Adds a configurable parameter that can be set at runtime.Parameter name.
Whether the parameter contains sensitive data (masked in UI).
Optional default value.
Parameters can be set via:
- Configuration (appsettings.json)
- Environment variables
- Command-line arguments
- User secrets (for secret parameters)
Azure Resources
See the Azure hosting integrations documentation for:AddAzureCosmosDBAddAzureStorageAddAzureServiceBusAddAzureKeyVault- And more…
External Services
AddExternalService
References an external service not managed by Aspire.Resource name for the external service.
Absolute URI of the external service (or parameter containing the URI).
Resource Naming
Name Validation
Method Chaining
All Add methods returnIResourceBuilder<T> for fluent configuration:
Complete Configuration
Related APIs
- IResourceBuilder - Configuring resources
- ContainerResource - Container-specific configuration
- ProjectResource - .NET project configuration