Session is a State Management Technique. A Session can store the value on the Server. It can support any type of object to be stored along with our own custom objects..

In general, the ways which are used in maintaining the Session State in the .NET application are

  • In-Proc, which stores session state in the individual web server’s memory. This is the default option.
  • Out-Proc / State Server, which stores session state in another process, called ASP.NET state service. It can also be run on a separate server.
  • SQL Server, which stores session state in a SQL Server database.


So, what are the options to maintain Session State in Azure Cloud?.
Table Storage
Table Storage Session Provider is, enabling developers to store session state in Azure Table Storage. It actually works by storing each session as a record in Table Storage. Each record will have an expired column that will have the expiry time of each session if it is not in use for certain time. The advantage of Table Storage Session Provider is its relatively low cost.
The disadvantage of Table Storage Session Provider is that it may not perform as fast as the other options.
We have to apply the following code snippet in web.config when using Table Storage Session Provider:

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

SQL Azure
SQL Azure session management is almost similar to SQL Server Session Provider. It can be used as storage for session state, it is cost effective, especially when you have an existing SQL Azure database, it performs better than Table Storage Session Provider in most cases. Expired session needs to be cleaned up by calling the DeleteExpiredSessions stored procedure.
We have to apply the following code snippet in web.config when using SQL Azure Session Provider:

<sessionState mode="SQLServer" 
    Database=myDataBase;User ID=[LoginForDb]@[serverName];
    Password=[password];Trusted_Connection=False; Encrypt=True;" 
    cookieless="false" timeout="20" allowCustomSqlDatabase="true" />

Azure Caching
The most preferable option available since it provides a high-performance, in-memory, distributed caching service. It is an out-of-process storage mechanism for ASP.NET applications.
We have to apply the following code snippet in web.config when using Cache Session Provider:

<sessionState mode="Custom" 
      <add name="AzureCacheSessionStoreProvider" 
    Microsoft.Web.DistributedCache" cacheName="default" useBlobMode="true" 
    dataCacheClientName="default" />

a. Azure Cache for Redis
Redis is another option for maintaining the session state on cloud. It is a fully managed, open source–compatible in-memory data store to power fast, scalable applications.
We have to apply the following code snippet in web.config when using Redis Cache Session Provider:

<sessionState mode="Custom" customProvider="MySessionStateStore">
    <!-- For more details check -->       
    <!-- Either use 'connectionString' OR 'settingsClassName' and 'settingsMethodName' OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. -->
    host="" accessKey="" 
    password=[password],ssl=True,abortConnect=False" ssl="true" port="6380" 
    throwOnError="true" retryTimeoutInMilliseconds="5000" 
    applicationName="CCLLogin" />


I have discussed above some of the available options for managing session state in Windows Azure. Azure Caching is the recommended option.
For more information, please write to us at