Disable ARRAffinity cause session issue - azure

I have a website which is developed using Kentico 10 and hosted on Azure.
It has Azure Application gateway, scaled out to 2 instances and webfarms are also enabled. Its using Azure Redis cache as well
Today I disabled ARRAffinity in the app service (via Azure Portal) and kept Cookies based affinity enabled in the application gateway.
Still, I can see the app is consuming the Redis cache however when I add an item to shopping cart and then click on the view cart it shows the empty shopping cart (randomly) where our shopping cart is stored in a session.
So I believe this is something related to sticky session issue even with the Redis cache.
Since I've disabled the ARRAffinity in the app service does is it required to disable the Cookies based affinity from the app gateway-> https settings?
If not, anything I've missed?

If you are using an App Service and scaling out to 2 instances the Application gateway does not provide load balancing capabilities.
The load balancing is being handled by the app service. If you wanting to control that a traffic manager profile might help.
So you would still need to leave ARR on in the app service.

Related

Load Balancing in Application Gateway with VMSS Cookie-based Affinity does not work

We have implemented an Azure App Gateway (Standard v1) which routes traffic to a VMSS containing a web server. When started, the VMSS has one instance of the web server.
We exercise the web server using SoapUI which makes requests via the App Gateway. Session Affinity is enabled in the App Gateway which, if my understanding is correct, is meant to make sessions "sticky" (i.e. when a session is commenced on one web server, all subsequent requests which belong to that session will be directed to that web server)
The VMSS scales out after 5 minutes of CPU activity above 75%.
As soon as the second Web Server is added to the VMSS, all requests fail.
We are adding the CORS cookies created by the App Gateway to each request in the understanding that it would direct the request to the appropriate web server but this does not seem to be happening.
Can anybody shed light on why this might be the case please?
(P.S. We have a similar configuration in an on-premises data centre with a traditional Load-Balancer and two web servers and it works perfectly).
Many thanks!

How to get access to azure app service instances directly via specific URL?

I have an Asp.Net MVC big e-learning site app that is hosted on azure(app service) with 10 instances.
We disabled ARR Affinity to improve performance and enabled traffic manager also.
Now I want to clear cache in every instance so how can I make a request for a specific instance? or is there any way we can clear cache using some receiver/messaging system?
If I enable ARR Affinity then I can make a request using a cookie.

Session state issue in Kentico site hosted in Azure

There is an application developed using Kentico 10 and hosted in Azure.
We recently install azure application gateway for this particular site,
In this site there is a function to add and view items to shopping cart.
So after installing the application gateway, the add and view items to shopping cart function won't work properly, Most of the time added items won't display when go to the view cart so its happening randomly, I suspect this is due to some issue on session state synchronization.
Our site URL is map to gateway and from there its goes to a application, and we do not have web farm as well, and session State mode is "InProc"
Since Azure Application Gateway is a web traffic load balancer
1- Does it required to setup a webfarm since we have azure application gateway?
2- Do i need to use "StateServer", "SQLServer" or "Custom" (e.g. Azure Redis Cache) since we have azure application gateway?
As long as you do not have multiple application connecting to same database, Web Farms are not necessary. However shopping cart is saved in session, cookie and DB and first point of retrieval would be session. Since azure app gateway has its session affinity you could try using that.
In case this does not help, you will need to use other storage (I believe redis cache to be the fastest), but point would be to better tie user with session.

Is the ARRAffinity cookie always set in azure web applications?

I a host web application on Azure. I have a basic plan where only one instance works. After I've published my app into cloud, I've noticed an automatically generated cookie called ARRAffinity. So even with single instance of hosted web application there will be always generated ARRAffinity cookie? Is that right? Or it doesn't matter how many instances are around and the Azure web application always generates the cookie?
It's always there by default.
There are ways to Disable Session affinity cookie (ARR cookie) for Azure web apps
Here's an explanation: Azure: ARRAffinity makes affinity cookies!
Affinity Cookies are used to aid people who need to stay with a certain instance of web app or web site in Azure. The reason for this is that we strive for statelessness, but do not always achieve it. This means that the user must stay on the particular instance that they using till they break state and then things are saved at that time.
This can be disabled without adding the Arr-Disable-Session-Affinity header that was mentioned in the blog post in the other answer. Azure has an option to turn this off under Settings > Configuration > General Settings > Platform settings.

Maintaining Session State in Azure WebApp

How can I maintain users to get redirected to the same Server in a Load-Balanced Web Apps
Your answer will be very helpful
Traffic Manager directs the user to the appropriate region, but assuming you have your web app scaled out to at least two instances, ARR (Application Request Routing) is what directs each request to a specific instance of the app.
ARR has a feature called Session Affinity which is enabled by default. It uses an ARRAffinity cookie to attempt to route all requests from a client to the same instance of your application. I say "attempt" because, the cloud being what it is, instances of your app can come and go due to autoscaling or maintenance activities.
Your best bet is to use Azure Traffic manager. When setup correctly it will route users to the proper cloud service in their region and provide them with the best possible experience.
More information can be found here
Azure Traffic Manager
Azure Traffic Manager Documentation
Traffic Routing Methods

Resources