X

Redis for .NET Developers – Redis running in Azure

redis-azure

In this post I wanted to go through the process of Redis running in Azure. Redis in Azure is called Azure Redis Cache. Azure offers a secure access to a dedicated Redis cache, which allows you to connect from any Azure applications.

There are certain tiers that are offered in Azure Redis:

  • Basic
  • Standard
  • Premium

I wont be going through each of them, since Azure does a good job in explaining the differences between the tiers but for this post we will be using the Basic.

First you will need to login to your Azure portal.
Once logged in.

  1. Click on New (+) sign, and it will open up the New Section
  2. Select the Databases option
  3. Select Redis Cache

    redis-azure1

Once you have selected the right option, then it is just 5 clicks away to create Redis

  1. Select a DNS name that is not used.
  2. Select your Resource Group.
  3. Select your Location.
  4. Select your pricing tier (I have selected Basic here, but feel free to choose the one that satisifies your needs)
  5. Click on Create.

    redis-azure2

  6. It takes a bit of time to create it, but you can see the progress.

    redis-azure3

One can access Redis using access keys and one can test it by launching the console.

Azure-Redis-Cache


The Console allows one to use Redis commands.

Azure-Redis-Preview-Console

When using StackExchange.Redis you can connect to the Redis instance, the information to connect to Azure is located in the Azure portal under Settings > Properties, one can use the sample code below to connect.

private static Lazy lazyConnection = new Lazy(() =>
{
    return ConnectionMultiplexer.Connect("whatever.redis.cache.windows.net,abortConnect=false,ssl=true,password=...");
});

public static ConnectionMultiplexer Connection
{
    get
    {
        return lazyConnection.Value;
    }
}

For other Redis topics

  1. Intro to Redis for .NET Developers
  2. Redis for .NET Developer – Connecting with C#
  3. Redis for .NET Developer – String Datatype
  4. Redis for .NET Developer – String Datatype part 2
  5. Redis for .NET Developer – Hash Datatype
  6. Redis for .NET Developer – Redis running in Docker
Categories: .NET Azure Redis
Tags: azureredis
Taswar Bhatti:
Related Post