Enable/Disable Affinity Cookie on Azure Function App

Affinity cookie is used to control the effective loading of the website and to ensure that all user requests are directed to the same server in any browsing session.

Enable Affinity Cookie on Azure Function :

  1. Navigate to Azure Portal
  2. Locate your Function App
  3. In Setting Pane, select Configuration
  4. Add New application setting
  5. Add Name as : PreferConnectionAffinity and Value : true
  6. click OK and save the setting
  7. Now when ever request will be send, it will be appending a affinity cookie to it and reach a dedicated server

Disable Affinity Cookie on Azure Function:
  1. Navigate to Azure Portal
  2. Locate your Function App
  3. In Setting Pane, select Configuration
  4. Add New application setting
  5. Add Name as : PreferConnectionAffinity and Value : false
  6. click OK and save the setting
  7. Now when ever request will be send, it will be distributed across servers

I tried above approach and the results were amazing, My azure function’s task was to update bulk records on Dynamics CRM/Data verse, Where we were experienced throttling issue, the reason was that the affinity cookie was enabled and even though we had dedicated 14 servers for this in backend but the load was not distributed across servers, So i added above configuration to Function app and disabled Affinity Cookie and boom the load distributed across servers. No throttling issue seen after that.

Referance links:

  1. https://azure.microsoft.com/en-in/blog/disabling-arrs-instance-affinity-in-windows-azure-web-sites/
  2. https://docs.microsoft.com/en-us/powerapps/developer/data-platform/api-limits#remove-the-affinity-cookie

One thought on “Enable/Disable Affinity Cookie on Azure Function App

  1. Pingback: Enable/Disable Affinity Cookie on Azure Function App - 365 Community

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s