No connection is available to service this operation: SET key while calling Redis Get from Azure Function
Hi, We are facing issues in both get and set method for Redis cache while calling from Azure Function . Both resources are deployed in Central US region.
Exception Message: No connection is available to service this operation: SET Offset
InnerException Message: at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
at StackExchange.Redis.RedisDatabase.StringSet(RedisKey key, RedisValue value, Nullable`1 expiry, When when, CommandFlags flags)
at Submission#0.Run(HttpRequestMessage req, TraceWriter log) in D:\home\site\wwwroot\RedisSetter\run.csx:line 32
Is this a temporary error?
If so, do you have a retry policy in your code that uses the Redis client? Azure can apply updates to your Redis instances - they do this one node at a time - any clients that are connected at that time will get this error until you reconnect. You are expected to implement an exponential backoff retry policy and are recommended to configure the redis client options to automatically reconnect. See "What do the StackExchange.Redis configuration options do?" here.
Sometimes we are able to connect. But, once connection fails, getting this exception continuously for hours.
We have exponential retry logic in place in Azure Function to retry.One more observation was using console application I am able to make connection and perform redis operations. But using Azure Functions at same point of time getting above exception. One thing might be is while calling from console app, it is a singleton connection. In case of Azure Function same function is being called by Logic App which are running in parallel based on a foreach loop of outer logic app. Although, these connections will be getting disposed after exit from azure function. Not able to figure out this exception is due to some max number of connections at an instance from a particular endpoint or how is it behaving.
The retry bits were fixed in the 1.2.x line - going to close this out to cleanup (several duplicates of the same issues we didn't follow up on), but do let us know if you're seeing a new issue. Error messages are also much more informative now, so they're easier to debug.