Scott Hanselman

Trying Redis Caching as a Service on Windows Azure

June 25, 2014 Comment on this post [15] Posted in Azure
Sponsored By


First, if you have already have an MSDN subscription (through your work, whatever) make sure to link your MSDN account and an Azure Account, otherwise you're throwing money away. MSDN subscribers get between US$50 and US$150 a month in free Azure time, plus a 33% discount on VMs and 25% off Reserved Websites.

Next, log into the Azure Preview Portal at  Then, go New | Redis Cache to make a new instance. The Redis Cache is in preview today and pricing details are here. both 250 meg and 1 GB caches are free until July 1, 2014 so you've got a week to party hard for free.


Of course, if you're a Redis expert, you can (and always could) run your own VM with Redis on it. There's two "Security Hardened" Ubuntu VMs with Redis at the MS Open Tech VMDepot that you could start with.

I put one Redis Cache in Northwest US where my podcast's website is.  The new Azure Portal knows that these two resources are associated with each other because I put them in the same resource group.


There's Basic and Standard. Similar to Website's "basic vs standard" it comes down to Standard you can count on, it has an SLA and replication setup. Basic doesn't. Both have SSL, are dedicated, and include auth. I'd think of Standard as being "I'm serious about my cache" and Basic is "I'm messing around."

There are multiple caching services (or Cache as a Service) on Azure.

  • Redis Cache: Built on the open source Redis cache. This is a dedicated service, currently in Preview.
  • Managed Cache Service: Built on AppFabric Cache. This is a dedicated service, currently in General Availability.
  • In-Role Cache: Built on App Fabric Cache. This is a self-hosted cache, available via the Azure SDK.

Having Redis available on Azure is nice since my startup MyEcho uses SignalR and SignalR can use Redis as the backplane for scaleout.

Redis Server managing SignalR state

Marc Gravell (with a "C") over at StackExchange/StackOverflow has done us all a service with the StackExchange.Redis client for .NET on NuGet. Getting stuff in and out of Redis using .NET is very familiar to anyone who has used a distributed Key Value store before.

  • BONUS: There's also ServiceStack.Redis from that includes both the native-feeling IRedisNativeClient and the more .NET-like IRedisClient. Service Stack also supports Redis 2.8's new SCAN operations for cursoring around large data sets.
ConnectionMultiplexer connection = ConnectionMultiplexer.Connect(",ssl=true,password=...");

IDatabase cache = connection.GetDatabase();

// Perform cache operations using the cache object...
// Simple put of integral data types into the cache
cache.StringSet("key1", "value");
cache.StringSet("key2", 25);

// Simple get of data types from the cache
string key1 = cache.StringGet("key1");
int key2 = (int)cache.StringGet("key2");

In fact, the ASP.NET team announced just last month the ASP.NET Session State Provider for Redis Preview Release that you may have missed. Also on NuGet (as a -preview) this lets you point the Session State of your existing (perhaps legacy) ASP.NET apps to Redis.

After pushing and pulling data out of Redis for a while, you'll notice how nice the new dashboard is. It gives you a great visual sense of what's going on with your cache. You see CPU and Memory Usage, but more importantly Cache Hits and Misses, Gets and Sets, as well as any extraordinary events you need to know about. As a managed service, though, there's no need to sweat the VM (or whatever) that your cache is running on. It's handled.


From the Azure Redis site:

Perhaps you're interested in Redis but you don't want to run it on Azure, or perhaps even on Linux. You can run Redis via MSOpenTech's Redis on Windows fork. You can install it from NuGet, Chocolatey or download it directly from the project github repository. If you do get Redis for Windows (super easy with Chocolatey), you can use the redis-cli.exe at the command line to talk to the Azure Redis Cache as well (of course!).

It's easy to run a local Redis server with redis-server.exe, test it out in develoment, then change your app's Redis connection string when you deploy to Azure.

Sponsor: Many thanks to our friends at Octopus Deploy for sponsoring the feed this week. Did you know that deploys with Octopus? Using NuGet and powerful conventions, Octopus Deploy makes it easy to automate releases of ASP.NET applications and Windows Services. Say goodbye to remote desktop and start automating today!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
June 25, 2014 12:19
Not that it _really_ matters, but is this on Windows under the covers?
June 25, 2014 12:38
What if I use Azure for my personal projects and my MSDN subscription is provided by my employer?
June 25, 2014 13:12
Cheers for the shout out; minor point:

Service Stack also supports Redis 2.8's new SCAN operations for cursoring around large data sets.

Just to clarify - that is also available in SE.Redis
June 25, 2014 13:27
Nice article. You mention there are currently 3 ways of doing caching in Azure. For an Azure Website what are the advantages of Redis Cache over the exising Managed Cache Service?
June 25, 2014 14:26
June 25, 2014 15:16
I have just started using Redis on Azure and it is fantastic, very easy to use especially with Marc's great work on StackExchange.Redis. Hopefully it will go GA soon. He also tipped me into the Pub/Sub functionality in Redis which is very easy to use and allows for mega performance using the combination of local and distributed cache.

The only disconcerting thing is that this is the 4th go Azure have had at caching, hopefully they are settled now! The Managed Cache Service seemed to be out of favor (removed from the portal) the day it was released.
June 25, 2014 17:22
What is the difference between using AppFabric caching vs. Redis caching? Especially as ASP.Net session state providers?
June 25, 2014 17:36
I'm looking forward for this feature on Brazil's datacenter.
June 25, 2014 20:44
Just like Andrew I'm wondering what the difference is between Redis Cache and the Managed Cache Service.

The redis is persistent (database key-value)? and the Managed Cache Service is completely in memory?

June 25, 2014 22:48
@Andrew @Edward @Daniel
We recommend using Azure Redis Cache for new Developments -

Both Azure Managed Cache and Azure Redis Cache work great as a traditional caches i.e. as performant key value stores.

However unlike traditional caches which deal only with key-value pairs, Redis is popular for its highly performant data types. Redis supports running atomic operations on these types, like appending to a string; incrementing the value in a hash; pushing to a list; computing set intersection, union and difference; or getting the member with highest ranking in a sorted set.

Other features include support for transactions, pub/sub, Lua scripting, keys with a limited time-to-live, and configuration settings to make Redis behave more like a traditional cache.

You can read more about Redis at
June 25, 2014 22:50
@Thiago We are working on support for Brazil and hope to have it available soon.
June 25, 2014 22:53
@Craig Forth time is a charm :-)

We do feel very confident recommending Redis cache as long term bet to customers for it is a proven Cache engine, with a a vibrant open source community around it.

June 26, 2014 1:54
@Dave: Ask your MSDN Licence provider at work, Don't just assume you can't, my work is just rolling out their new MDSN Licencing and they've told us we can use our MSDN sub with Azure on our own person projects.
June 27, 2014 23:11
When using Azure through your MSDN Subscription it's only for Dev/Test.
-But that can be Your personal fun stuff. MSDN Subscriptions are personal even if they are purchased by your employer.
July 21, 2014 19:51
Is there any recommendation between sql server 2014 session provider and redis cache for storing session state?

We have having problems with performance and reliability on azure's managed cache for session state and we are looking for an alternative.

Is there is any performance data on managed cache vs redis cache for session state?


Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.