locked
How to use Azure Table Storage to store Sessions ??? RRS feed

  • Question

  • Hi all,

    I had put aside this problem for a few days as I was using SQLServer to store my sessions. Now I have a major problem with using SQLServer to store sessions. So I want to use Azure Table Storage to store sessions.

    I browsed through so many blogs and also msdn stuff to know how exactly it is done. I did not find anything that was helpful to ME.

    So, here is what I have done till now to use Table storage for storing sessions.

    1. I have modified the sessionState in Web.Config as told by most of the people. And here's how it looks now

    <sessionState mode="Custom" customProvider="TableStorageSessionStateProvider" >
    <providers>
    <clear/>
    <add name="TableStorageSessionStateProvider" type ="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider" />
    </providers>
    </sessionState>

     
      2. Then I added the AspProviders.dll to the References. Here is how I did that. First I opened my AzureWebApplication. Then I right clicked on "References" under the MyWebRole. Then clicked on Add Reference. In this pop up window, I then clicked BROWSE. I browsed the AspProviders.dll from on of the AspProviders project that I had found on the codeplex.(This dll was found in the webproject's BIN -> DEBUG -> AspProviders.dll ). Then I clicked OK.
     

    3. After this I added few things in the ServiceDefinition.csdef and ServiceConfiguration.cscfg files. Here is what I added.  In the ServiceDefinition file i added

    <ConfigurationSettings >
    <Setting name="DataConnectionString" />
    <Setting name="AccountName" />
    <Setting name="AccountSharedKey" />
    <Setting name="TableStorageEndpoint" />
    <Setting name="BlobStorageEndpoint"/>
    <Setting name="QueueStorageEndpoint" />
    </ConfigurationSettings>

    and in the ServiceConfiguration file I added

    <Setting name="AccountName" value="myAccountName" />
    <Setting name="AccountSharedKey" value="someLoooooooooongKey" />
    <Setting name="TableStorageEndpoint" value="http://myAccountName.table.core.windows.net/" />
    <Setting name="BlobStorageEndpoint" value="http://myAccountName.blob.core.windows.net/" />
    <Setting name="QueueStorageEndpoint" value="http://myAccountName.queue.core.windows.net/" />
     

    4. Then I try to run the application and there is this configuration error that throws up.


    Can you please help me with using the Azure Table Storage for storing sessions...
     

    Thanks in advance

    Regards

    Sandeep

    Wednesday, August 17, 2011 12:02 PM

Answers

All replies

  • I had major issues with the "AspProviders" samples. 

    There is a project on Codeplex doing this: http://azureproviders.codeplex.com/  Basically they have build a custom provider and stored it in Table storage.

     


    Dampee (blog | twitter)
    • Proposed as answer by Seetha_ Thursday, August 18, 2011 8:08 AM
    Wednesday, August 17, 2011 12:35 PM
  • I'd actually recommend exploring the user of Azure AppFabric cache and their session provider. Compared with the cost of rolling your own session provider, it can be a good option. Just make sure you pick the right size cache based both on your storage and concurrent connection needs.
    Wednesday, August 17, 2011 1:37 PM
  • Hi, you can check out this link for step by step how to using Azure Storage Provider

    http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_buildingaspnetappswithwindowsazure_topic4#_Toc300153323


    regards, wely
    • Marked as answer by MBytes Thursday, August 18, 2011 8:36 AM
    Thursday, August 18, 2011 1:30 AM
  • Hey guys,

    Thanks a lot for the information. Especially wely_live 's link really helped me a lot. BUT unfortunately, it did NOT work well for me.

    I am getting an error. The screenshot of the same is shown below.

     

    Is there anything else that i need to do TO OVERCOME this problem

    Regards

    Sandeep

    Thursday, August 18, 2011 5:54 AM
  • Hi all,

    FYI, I have replaced the entire 1,2,3 and 4 steps with the things that were suggested in this link

    http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_buildingaspnetappswithwindowsazure_topic4#_Toc300153323

    The error still remains ... I have NOT found any solution to the above error pertaining to serialization.

    Regards

    Sandeep


    Thursday, August 18, 2011 6:35 AM
  • If you try to store a custom object inside session which uses SQL Azure / Azure Storage, you will need to mark the class with [Serializable] attribute.

    Similar case:  http://forums.asp.net/p/1355470/2783677.aspx


    regards, wely
    Thursday, August 18, 2011 6:42 AM
  • Hi wely_live,

    I have not stored any objects in the session. I guess the problem is with respect to ajax.

    What happens is that I use an iframe to load few required HTMLs. These HTMLs are used to complete a task on my application. After the tasks are completed, you have press a OK button. The HTMLs are loaded using ajax. So when the I hit OK button, this error pops up.

    Can you find a solution to this ???

    Regards

    Sandeep

    Thursday, August 18, 2011 8:40 AM