4
votes

I have a MVC3, ASP.NET 4.5 web application deployed on Azure Websites, using SQL Azure.

Currently I am using some "inproc" Session variables which I need to remove since I am going to start using multi website instances. I could just store the Session variable values in the SQL Azure DB, but I am also using TempData, which also uses Session state, "under the bonnet". Due to TempData use, I do need to implement an "out of proc" session solution.

I have seen some recommendation for using AppFabric caching, but I am unsure whether this is still current, and whether it is correct for Azure websites.

Also my development setup is on a Windows 7 machine with SQL Server 2008 R2. So a solution should be transferable with minimum pain.

There is also a "thread agility" issue with session variables, and a open source solution has been created using REDIS caching, but I have no experience of this, or REDIS. See: GitHub site

So thoughts I have are:

1) Angieslist/AL-redis custom provider, see: GITHUB link . Not entirely sure that this can be used in a Azure Websites application.

2) Appfabric. Not sure if this is relevant or current for Azure Websites.

3) SQL Azure session provider.

4) Azure Table storage.

5) Use a custome TempData provider to persist via cookies ie https://www.nuget.org/packages/BrockAllen.CookieTempData.dll/1.2.2, and then remove other session variables.

I would be very grateful for advice on a good Azure Websites session implementation mechanism which is simple. My data is pretty simple. I think I have one object which I quess I will need to serialize, probably via Json.NET

2
I would suggest Redis Cache as along as you are ok with leveraging a Preview feature in your solution. Otherwise, Websites does support sticky sessions (client->server affinity) which in most cases will route the user to the same machine they were using before so the machine should still have their session details.cory-fowler
Thanks for this. Our site is in production so "Preview feature" may not be the wisest choice. I need to read up on sticky sessions, as I was a little unaware of this, but basically "inproc" will work.SamJolly

2 Answers

9
votes

If you have more than one instance of an Azure Web Site, sticky sessions are enabled by default by the load balancer. This means that a user will be directed to the same instance (server) and that you'll be able to use session state in your app.

1
votes

You may also find the Distributed Caching section (Ch 12) of this ebook helpful http://aka.ms/CloudApps_PDF