We have an AspNetZero app currently deployed on an Azure WebApp that runs between 3 and 5 instances at a given time. Currently we are using the default in-memory cache provider, but I am looking to changing this to Redis. If we do that (by creating an Azure Redis cache and uncommenting the Redis config in WebCoreModule), will Abp use Redis for its session info also?
I would like to disable the Afinity Cookie in the Azure web app so that user sessions are no longer sticky to a specific machine and can be served by any machine in the cluster for any request (with all session state being in Redis). Is that the only change needed? Or is there something different for session storage?
Thanks, Bryan
4 Answer(s)
-
0
Hi Bryan
- Install the Abp.RedisCache NuGet package to your application (you can install it to your Web project, for example).
- Add a DependsOn attribute for the AbpRedisCacheModule and call the UseRedis extension method in the PreInitialize method of your module
- Set your Redis connection string by adding it to the config file.
Further information:
- <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Caching?searchKey=Redis%20#redis-cache-integration">https://aspnetboilerplate.com/Pages/Doc ... ntegration</a>
- <a class="postlink" href="https://redis.io/documentation">https://redis.io/documentation</a>
PS: I liked that you stated your current AspNet Zero technology in your signature.
-
0
Thanks. I did see all of the documentation for the Redis setup. I just wanted to confirm that AbpSession would automatically utilize that so that if I disabled sticky sessions on Azure I would not break anything. Because ABP does its own session management, I just wasn't sure.
Thanks again, Bryan
P.S. -- I have found just keeping my sig updated is easier than including my Zero version in every post. ;)
-
0
@alper,
I have setup a local redis cache and made the necessary changes to ABP. When I look at the cache, I see a bunch of standard Abp stuff in there (AbpApplicationSettings, TenantSettings, UserSettings, etc). However, I don't see anything related to user sessions. My goal is to eliminate the in-memory session provider so that I can turn off sticky cookies on our Azure web cluster.
This web page goes through the "normal" steps to do that with an ASP.Net web app : [https://docs.microsoft.com/en-us/azure/redis-cache/cache-aspnet-session-state-provider]). However, I know that Abp uses it's own session management, so I wasn't sure if anything else needed to be done to ensure that the session state was being stored in the cache and not in the web server. I'm sorry to ask again, but your response didn't speak directly to the session question that I am trying to resolve.
Thanks, Bryan
-
0
hi,
Session state is being stored in client's cookie. As long as this cookie is being decrypted correctly against multiple Azure servers there'll be no problem. You can use Redis cache to store your sensitive data to prevent lost after server restarts.