1
votes

Is there is a quick, cheap, reliable session-state mechanism available for Free F1 WebApp ASP.NET for demonstration configurations?

I know Windows Azure Session management is discussed a lot on SO, but this particular configuration issue seems to slip through the cracks.

The available configuration options seem to be:

The bottom line seems to me that there isn't. I would really appreciate it if someone could prove otherwise.

EDIT:

I've been thinking about and tinkering with this throughout the day. My findings so far are:

1) Upgrading to the D1 WebApp service plan improves the reliability of the session-state management considerably but it is still prone to unpredictability. As Hrvoje Hudo points out below you can't expect reliability with Free or Shared.

2) Installing ASP.NET Universal Providers would seem to be a solution. I created a new MVC WebApp project using MSVC2013, selected Azure hosting, typed:

install-package Microsoft.Aspnet.Providers 

in the package management console, added: Session["Time"]=DateTime.Now.ToString() to the Home Index view and referenced it in the about View using:

ViewBag.Message = Session["Time"] 

And updated the web.config to:

<sessionState mode="Custom" customProvider="DefaultSessionProvider"  timeout="1">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=Whatever" connectionStringName="DbaseName"/>
  </providers>
</sessionState>

When I publish the website the default database is created on my Azure SQL Server, courtesy of the publish scripts.json containing all my config settings and swapping them in, and a dbo,session table is created on the database.

Browsing to the website, new sessions are created on the database table - I can see them using MS Management Studio 2013 - and deleted after they time out (60s+).

I downgraded the website to Free (to be sure it wasn't configured to a higher plan by default, which MSVC used to do) and everything still seems to work. This seems to be what I was looking for.

3) Azure Tables. Can't get my head around these yet! If anyone knows of a good "how to" tutorial I'd love to look at it.

EDIT 2:

After a day's soak testing I'm now 90% convinced ASP.NET Universal Providers is the way to go for quick & reliable sessions using a Free Azure Web App. I can't says it's free, as the SQL Server must be paid for (Basic = ~£4pm See: https://azure.microsoft.com/en-gb/pricing/details/sql-database/) , but it's certainly not expensive, and if you're using an SQL Server anyway - like me - it makes sense.

1
Everywhere I go there's confusion about scripts for the Universal Providers route. Is it auto-creating the db/tables? Are you able to share the script or link to it? Thanks!Savage
Sorry, I see now that it auto-creates a table called Sessions in the database provided via the connection stringSavage

1 Answers

1
votes

There's no "silver bullet" session state, that's why you have all those options, chose what fits best with your requirement and business case. For Free web app you can't expect reliable service, Azure will restart your app pool regularly and there are lot of limits, so default InProc can be an issue - but again you're using Free tier. So since you want to save few bucks - invest time into writing your own, which uses Azure Storage (table or blob, I would use Table) or some other storage mechanism.