Windows Azure Shared Cache feature is going to depreciate soon and right now Microsoft is not allowing the end users to create new shared cache namespace from the management portal.
One of the Microsoft partner, who was leveraging Shared Cache to managing the ASP.NET Session state for their Deployed CloudServices got this information from some resources, and approached me to understand the alternatives. I have suggested them to go for a Role based cache feature as mentioned in this article, and provided below mentioned msdn document for smooth migration from shared cache to Role based Cache :
- Migrate from Windows Azure Shared Caching to In-Role Cache http://msdn.microsoft.com/en-us/library/windowsazure/hh914160.aspx
This particular partner was on Windows Azure SDK 1.7, which doesn’t support the Role based Cache (RTM) feature, so they have migrated their CloudService application to latest version of Windows Azure SDK, and then migrated to Role based cache by following the above mentioned msdn article. The migration part went smoothly, however while accessing the session state from application, they were start getting below mentioned exception.
“Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.
Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the
<configuration>\<system.web>\<httpModules> section in the application configuration.”
> In general, the above mentioned exception related to ASP.NET sessions will be thrown due to one of the below reasons
- Session is not configured properly or explicitly disabled the SessionState by changing enableSessionState property to false.
- The modules/binaries for session state management were missing
> Rule out the possible configuration, I have reviewed the web.config and page directive, however, I couldn’t find any thing suspicions, which caused this behavior.
> Rule out the issue with the cache module, I have manually checked the project references for cache references added by Cache SDK 2.2 NuGet package,and I can see all the required binaries for managing role based cache were already added in the project reference.
> To get the more granular details on the issue, I have created a new .aspx page, and added below mentioned code snippet to add data to the Cache object.
DataCacheFactory factory = new DataCacheFactory();
DataCache cache = factory.GetCache("default");
> After running the page with above code snippet throws more meaningful error message as mentioned below :
System. MissingFieldException was unhandled by user code
Message=Field not found: 'Microsoft.Fabric.Common.IOCompletionPortWorkQueue.WORKER_THREAD_IDLE_WAIT_TIME'.
at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetNewClientDrm(String cacheName, SimpleSendReceiveModule tempModule,
at Microsoft.ApplicationServer.Caching.DataCacheFactory.CreateRoutingClient(String cacheName, NamedCacheConfiguration config,
at Microsoft.ApplicationServer.Caching.DataCacheFactory.CreateNewCacheClient(DataCacheDeploymentMode mode, String cacheName,
at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate,
at Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName)
at eLearnWebRole.Test.Page_Load(Object sender, EventArgs e) in D:\Asp.Net\eLearnWeb\eLearnWebRole\Test.aspx.vb:line 11
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
It is recommended to go through below mentioned Windows Azure Cache articles :
- Best Practices for using Windows Azure Cache/Windows Server Appfabric Cache
- Capacity Planning Considerations for In-Role Cache (Windows Azure Cache)