A cloud-native app can leave you juggling APIs, databases, caches, and a growing pile of connection strings. Getting a fresh clone running becomes a hunt for the right ports, secrets, and startup order.
.NET Aspire brings local orchestration and integrations together so you can focus on the app instead of wiring services by hand. Its AppHost project is the local orchestrator that wires resources.
✅ Figure: Good example - AppHost wires each service to its dependencies; Web receives the API endpoint, while only the API receives the database connection and Orders key
See Aspire external parameters and environment-variable injection for configuration details.
Document any extra configuration needed to launch a service outside AppHost.
Set up a Redis container (e.g., using Docker Compose).
services:redis:image: redis:latestcontainer_name: redis-cacheports:- "6379:6379"command: ["redis-server", "--requirepass", "examplepassword"] # Local example onlyvolumes:- redis_data:/data # Persist data locallyvolumes:redis_data:driver: local
Write custom code to handle connection strings and inject them into your application (this needs to be manually kept in sync with all your environments).
var redisConnection = Environment.GetEnvironmentVariable("REDIS_CONNECTION_STRING")?? throw new InvalidOperationException("REDIS_CONNECTION_STRING is required.");services.AddStackExchangeRedisCache(options =>{options.Configuration = redisConnection;options.InstanceName = "Northwind";});
❌ Figure: Bad example - Redis setup and application configuration must be kept in sync manually
Docker Compose remains a valid choice. Aspire removes this example's manual connection wiring; it does not remove the need to configure each environment.
Aspire handles Redis setup and connection string injection for you. In AppHost, configure the Redis resource and reference it from the API:
var builder = DistributedApplication.CreateBuilder(args);var cache = builder.AddRedis("cache");builder.AddProject<Projects.NorthwindApi>("api").WithReference(cache).WaitFor(cache);builder.Build().Run();
In the API project, install Aspire.StackExchange.Redis.DistributedCaching and register IDistributedCache using the same resource name:
var builder = WebApplication.CreateBuilder(args);builder.AddRedisDistributedCache("cache");
✅ Figure: Good example - AppHost supplies the connection for the named Redis resource
The API still uses IDistributedCache, while AppHost manages the local Redis container and supplies its connection string. See the Redis distributed caching integration for package and setup details.
Follow the Aspire getting-started guide.
Try Aspire by running the SSW.CleanArchitecture template.