Craig
Craig

Reputation: 36816

Connecting to Azure Redis Cache

I am trying to connect to the Preview Azure Redis Cache with the following code.

var options = new ConfigurationOptions();
options.EndPoints.Add("myname.redis.cache.windows.net", 6379);
options.Ssl = true;
options.Password = "VeryLongKeyCopiedFromPortal";
var connection = ConnectionMultiplexer.Connect(options);

When I do this I get the exception

"It was not possible to connect to the redis server(s); to create a disconnected multiplexer, disable AbortOnConnectFail"

What can be causing this?

Upvotes: 8

Views: 19009

Answers (3)

Felipe Augusto
Felipe Augusto

Reputation: 1553

from local in C#, you can use like this ...

"localhost, port:6379, password=value"

Upvotes: -1

James Davis - MSFT
James Davis - MSFT

Reputation: 1806

I had this same issue. Make sure you copied the key correctly :)

My issue was I didn't copy the base 64 encoded key properly from the UI. Consider the two keys below. The way I usually copy/paste a non broken string is by double clicking. When I double clicked on the key I got the first set of data and not the entire string.

8Rs0Uvx7aaaaaaaaTjaoTu11bz0qOm/o5E8dtWPXtrc=
8Rs0Uvx7aaaaaaaaTjaoTu11bz0qOm

Upvotes: 1

Mike Harder
Mike Harder

Reputation: 276

The port for SSL is 6380. Port 6379 is used for non-SSL. StackExchange.Redis defaults to these ports if not set, so you should be able to just remove the port from your code, like so:

var options = new ConfigurationOptions();
options.EndPoints.Add("myname.redis.cache.windows.net");
options.Ssl = true;
options.Password = "VeryLongKeyCopiedFromPortal";
var connection = ConnectionMultiplexer.Connect(options);

Alternatively, you can use a connection string instead of the ConfigurationOptions object:

var connection = ConnectionMultiplexer.Connect(
    "myname.redis.cache.windows.net,ssl=true,password=VeryLongKeyCopiedFromPortal");

Upvotes: 12

Related Questions