Enable Session Persistence with Sticky Cookies
Enable persistent sessions using cookies in an App Gateway. The sticky cookie is forwarded to the same backend server.
You only need to use sticky support when you have multiple origins, and you do this by creating a NGINX upstream block .
Sticky Parameters
upstream {
  sticky;  
  server 127.0.0.1:9001;
  server 127.0.0.1:9002;
}
  sticky [hash=index|md5|sha1] [no_fallback]
       [name=route] [domain=.example.com] [path=/] [expires=1h] [secure] [httponly];
   or
  sticky [hmac=md5|sha1 hmac_key=<foobar_key>] [no_fallback]
       [name=route] [domain=.example.com] [path=/] [expires=1h] [secure] [httponly];
   or
  sticky [text=raw] [no_fallback]
       [name=route] [domain=.example.com] [path=/] [expires=1h] [secure] [httponly];Server Selection Algorithm
| Algorithm | Description | 
|---|---|
| hash | The hash mechanism used to encode upstream server. It can't be
                                    used with  The default is  | 
| hmac | The HMAC hash mechanism used to encode upstream
                                server It's like the hash mechanism but it uses hmac_keyto secure the hashing. It can't be
                                used withhashortext. | 
| hmac_key | The cryptographic key to use with hmac. Set ahmac_keyif you usehmac. | 
| no_fallback | Set this flag so that if a request comes with a
                                cookie and the corresponding backend is unavailable, a 502 (Bad
                                Gateway or Proxy Error) is returned. You can set it to the upstream
                                block, or set sticky_no_fallbackin a server or
                                location block. | 
Cookie Settings
| Setting | Description | 
|---|---|
| name | The name of the cookie used to track the persistent upstream server. The default is route. | 
| domain | The domain in which the cookie is valid. The default is nonewhen the browser handles the domain. | 
| path | The path in which the cookie is valid. The default
                                is /. | 
| expires | The validity duration of the cookie. The default is
                                         Enter a value to have the cookie expire after the specified time. The value is set relative to the client, and it must be for a period greater than one second. | 
| secure | Enable secure cookies (transferred only using https). | 
| httponly | Tells the browser that the cookie can only be accessed by the server. |