AddStackExchangeRedis doesn't read Aspire connection string
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
I'm using `AddStackExchangeRedis()` method to setup SignalR's Redis backplane. However, the API service can't connect to the Redis instance.
Here's the code from AppHost's Program.cs
```cs
var builder = DistributedApplication.CreateBuilder(args);
var redis = builder.AddRedis("redis-cache");
builder.AddProject("blazorsingalrapp1")
.WithReference(redis);
builder.Build().Run();
```
And here's how the API service (BlazorSingalRApp1) project's program.cs is configured
```cs
builder.Services.AddSignalR()
.AddStackExchangeRedis("redis-cache", options =>
{
options.Configuration.ChannelPrefix = "MyApp";
options.Configuration.AbortOnConnectFail = false;
});
```
However, when I run the apphost, the backend API service can't connect and the logs show
```
fail: Microsoft.AspNetCore.SignalR.StackExchangeRedis.RedisHubLifetimeManager[7] Not connected to Redis.
StackExchange.Redis.RedisConnectionException: UnableToConnect on redis-cache:6379/Subscription
```
It appears that maybe AddStackExchangeRedis call doesn't honor the connection string coming from Aspire because at runtime `config.GetConnectionString("redis-cache")` has the right connection string.
### Expected Behavior
_No response_
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version info
9.0
### Anything else?
Aspire 9.3.1
Contributor guide
Assessment
This issue has not been assessed yet.