skip to Main Content

i am implementing Azure Redis Cache to solve session issue for my Azure hosted application below is the code i written.

enter image description here

do we need to do any confiuration changes for Redis in Azure portal.
please help.

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    the same error i got, and the status of redis is running, added images for reference enter image description here

    enter image description here

    i have added my IP also in the Redis Firewall.

    did i need to do any thing more Gong.


  2. I did some test on my side and this is my test console app code :

    using System;
    using StackExchange.Redis;
    
    
    namespace redistest
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                SetString("id","abcd");
    
            }
    
            private static Lazy<ConnectionMultiplexer> lazyRedisConnection = new Lazy<ConnectionMultiplexer>(() =>
            {
                return ConnectionMultiplexer.Connect("<connection string>");
            });
    
            public static void SetString(string key ,string value)
            {
                var con = lazyRedisConnection.Value;
                IDatabase db = con.GetDatabase();
                db.StringSet(key,value);
    
                Console.WriteLine(db.StringGet("id"));
                Console.ReadKey();
            }
        }
    }
    

    Result :

    enter image description here

    Seems everything works as excepted. I got the same error in the beginning:

    No connection is available to service this operation

    It is due to Azure Redis service has not been created yet. it will take several minutes to finish this process. You can check its status here :
    enter image description here

    When its status is Running, you can try to connect to it.

    In the whole process, I have no additional configs for my Redis service,all I have done is: create Redis=>wait it be created => find the connection string => connect to it by code.

    Actually I configed nothing on my Redis. Everything works for me. I am not sure if it is related to the version of StackExchange.Redis, some people get this error when using 2.xx version and when they get back to 1.2.6, this issue is no longer appears . You can have a try. Hope it helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search