I want to use a global data for MVC web application running on Windows Azure (e.g. something like a list of users having new messages).
For a normal webapp, I could use some per-appdomain storage like AppDomain.SetData or just static variable. What should I use for Azure instead (cache? blob storage? queues?) and what solution would be the fastest one?
AppFabric Cache is an excellent fit for sharing data between roles (or instances of the same role). The interesting thing about AppFabric Cache is that it doesn't apply just to ASP.NET Session State - there just happens to be an out-of-the-box ASP.NET Session State Provider that sits atop the cache.
Using the cache is nearly trivial. Here's a snippet from a command-line console app demo:
var dataCacheFactory = new DataCacheFactory(); DataCache dataCache = dataCacheFactory.GetDefaultCache(); Console.Write("Enter a string to cache: "); string value = Console.ReadLine(); dataCache.Put("key", value); string response = (string)dataCache.Get("key"); Console.WriteLine("Cached string: " + response);
Using it as a Session State provider requires zero code change - it's all driven by the app.config / web.config.
vtortola makes a good point about the AppFabric Cache being in CTP, but we should see that in production in the near-term.
Table Storage will work as well, depending on the complexity of your queries.It sounds like your queries would be relatively straightforward.
Since pricing hasn't been announced yet for AppFabric Cache, this could factor into your decision vs., say, Table Storage which runs $0.15 / GB plus related transactions (although transactions won't likely have any noticeable impact on your cost, at $0.01 per 10,000 transactions).
EDIT June 7, 2012 Pricing info has changed since original answer: