1

Once you consume and set Azure ARRAffinity response cookie and send it back to Azure, are you supposed to get it back with next response ?

I just completed bit of code what brings Azure response cookie all the way to browser, sets it as a session cookie and then I pass it back to Azure in request as a cookie. To my surprise I am not getting this cookie back, I see it only the first time. However I have a feeling this might be expected behaviour - I could find anything in the documentation. When I try to change the cookie to some made up value, the correct cookie is returned with the next response.

public class RestRequestWithAffinity : RestRequest
{
    public RestRequestWithAffinity(string resource, IRequestWithAffinity request)
        : base(resource)
    {
        if (!string.IsNullOrEmpty(request.AffinityValue))
        {
            AddCookie("ARRAffinity", request.AffinityValue);
        }
    }
}

 var request = new RestRequestWithAffinity(url, feedRequest)
        {
            Method = Method.GET
        };

// cookie doesn't come back when already in request
IRestResponse response = await _client.ExecuteTaskAsync(request);
Vojtiik
  • 2,558
  • 1
  • 17
  • 21
  • 1
    you are not supposed to interfere with this cookie manually. what are you trying to achieve ? – astaykov Jun 16 '15 at 19:06
  • I pass this cookie through series of stateless micro services, I am afraid I do need to touch it. – Vojtiik Jun 17 '15 at 08:40
  • 1
    if **you** create the cookie, than choose a different name and everything will be fine! `ARRAffinity` is a reserved name by the IIS ARR Module. And that's why you may see this misbehavior – astaykov Jun 17 '15 at 14:39

2 Answers2

0

Yes, you supposed to get it back with next response. You can take a look on the following link:

http://azure.microsoft.com/blog/2013/11/18/disabling-arrs-instance-affinity-in-windows-azure-web-sites/

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • I read the doc before and in the ordered list under the first paragraph it says only steps 7-9 are repeated with subsequent requests. To me that means I should not get it back. – Vojtiik Jun 17 '15 at 08:56
  • "When the client submits a subsequent request, it includes the cookie in it" it means that every request it should send the cookie, in my opinion – Thiago Custodio Jun 17 '15 at 13:06
0

if you create the cookie, than choose a different name and everything will be fine! ARRAffinity is a reserved name by the IIS ARR Module. And that's why you may see this misbehavior.

Also pay attention that if you use the public Microsoft provided domains (i.e. yourdomain.cloudapp.net or yourdomain.azurewebsites.net) you cannot set the cookie at top domain level - i.e. you cannot set cookie for the cloudapp.net domain or for the azurewebsites.net domain. You shall always use the full domain, including any subdomains to set the cookie - i.e. yourdomain.azurewebsites.net.

Take a read here for more information about that issue: https://publicsuffix.org/learn/

astaykov
  • 30,768
  • 3
  • 70
  • 86