I am running a .NET application inside a Docker container and trying to connect it to an Azure Redis Cache instance. While I can successfully connect to the Redis instance using redis-cli from within the Docker container, the .NET application fails to connect and gives the following error:
"StackExchange.Redis.RedisConnectionException: It was not possible to connect to the redis server(s). Error connecting right now. To allow this multiplexer to continue retrying until it's able to connect, use abortConnect=false in your connection string or AbortOnConnectFail=false; in your code.n at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(ConfigurationOptions configuration, TextWriter log, Nullable`1 serverType, EndPointCollection endpoints) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 708n at StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 673n at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 651n at Program.<Main>$(String[] args)
I have correctly configured appsettings.json and added it to my program.cs
Verified the connection to Azure Redis Cache using redis-cli from within the Docker container:
redis-cli -h ghsdata.redis.cache.windows.net -p 6380 --tls
This works and I can run commands like PING and SET.
Configured appsettings.json with the correct connection string, including the hostname, password, and SSL settings.
Verified Docker Compose setup to ensure the appsettings.json is correctly mounted and environment variables are passed.
What shall I do to resolve this error?
Configured appsettings.json with the correct connection string, including the hostname, password, and SSL settings.