Microsoft Azure Redis Cache in Kentico


This article is a step-by-step guide on how to use Microsoft Azure Redis Cache as a session state provider in Kentico 8.1

Azure Redis Cache is based on the popular open source Redis Cache and is now accessible from any application which runs on Azure – that also includes Kentico.

Setting it up for Kentico Azure projects is quite easy. After you create a new Redis Cache resource via new Azure Portal, all you need to do to store ASP.NET session state in this type of cache is open the project in Visual Studio, right-click the solution and select Manage NuGet Packages. Search for RedisSessionStateProvider package and install it. This action will automatically add all required assembly references to the project and create the following section in a web.config file where you can specify details – especially host name and access key which you can find in the properties of the cache on Azure:

<sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <!-- <add name="MySessionStateStore" host = "" [String] port = "" [number] accessKey = "" [String] ssl = "false" [true|false] throwOnError = "true" [true|false] retryTimeoutInMilliseconds = "0" [number] databaseId = "0" [number] applicationName = "" [String] connectionTimeoutInMilliseconds = "5000" [number] operationTimeoutInMilliseconds = "5000" [number] /> --> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="" accessKey="..." ssl="true" /> </providers> </sessionState>

After making these changes, please make sure to comment out the standard InProc session state provider:

<!-- <sessionState mode="InProc" customProvider="DefaultSessionProvider"> <providers> <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" /> </providers> </sessionState> -->

With this configuration in use, you are ready to deploy the project to Azure and start utilizing the new Azure Redis Cache as a session state provider.

A complete guide about Azure Redis Cache and its configuration can be found in Microsoft documentation - How to Use Azure Redis Cache.

Share this article on   LinkedIn

Filip Ligač

Hi, I work as a Cloud Support Specialist here at Kentico. I write about Microsoft Azure and and am trying to extend knowledge about the best practices for deployment.