Typos in Azure Redis Cache access keys can result in headaches

Have you ever encountered the following error: StackExchange.Redis.RedisConnectionException? With this post I hope to save you time that I lost in my struggle finding the answer.

A few weeks ago I ran across a big yellow screen exception stating:

StackExchange.Redis.RedisConnectionException: No connection is available to service this operation: EVAL

After some Googling I was heading in the complete wrong direction assuming that the Redis Cache was somehow corrupted and required to be flushed. So the next thing I did is login into the Azure Portal desperately looking for a way to restart or flush the Redis Cache. I guess it was not my lucky day :)

Because I already had yellow belt Powershell skills, I decided to look for a programmatic way of flushing the Redis Cache. Jackpot! Check out the following article from Aaron Saikovski containing the script: How to flush the Azure Redis Cache with PowerShell.

I copied the code, added the host and key from the web.config, ran the script and BAM:

Exception calling "Connect" with "2" argument(s): "It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail. SocketFailure on PING"

Back to the drawing board! The most logical solution to me at this time was to delete the Redis Cache and recreate it. To make a long story short, I noticed after creating the new Redis Cache that the access key that I used previously had a small typo (missing the equals sign at the end). After correctly copy/pasting the key all started working again!

I guess that is why in Azure portal they have these nice little buttons to copy the keys :)

Copy key