urig
urig

Reputation: 16841

Azure Redis Cache: "role discovery data is unavailable"

I'm trying to connect to an instance of Azure Redis Cache from my local dev machine. I'm using StackExchange.Redis like so:

var lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
    return ConnectionMultiplexer.Connect(
        $"{redisServerUrl},abortConnect=false,ssl=true,password={redisServerKey},connectTimeout=10000,syncTimeout=10000");
});

When lazyConnection is called I get an InvalidOperationException with the message:

"role discovery data is unavailable"

and this one-liner stack trace:

Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.get_CurrentRoleInstance()

Why is the exception thrown and how can I avoid it?

Upvotes: 0

Views: 254

Answers (1)

JonCole
JonCole

Reputation: 3122

StackExchange.Redis tries to discover the RoleInstance name under the covers if you don't specify a ConfigurationOptions.ClientName value. It is odd that you are getting this error bubbled out to your code because the code in question handles all exceptions and defaults back to returning the Computer name.

I suspect that if you add ",name=XXX" to your connection string, the error will go away because you will avoid that code path.

Upvotes: 1

Related Questions