79497396

Date: 2025-03-10 08:21:02
Score: 1
Natty:
Report link

Thank you @Andrew B for the comment.

Yes, it’s possible that further requests from the user who was on the unhealthy instance could fail if the user is redirected to a different instance after the restart. This happens because the `ARRAffinity` cookie is tied to the unhealthy instance and will no longer be valid once the instance is restarted.

- If the session state is not persisted externally like using Azure Redis Cache, the user may lose their session or be logged out. To avoid this, consider storing session data externally so users can maintain their session even if they are redirected to another instance.

- Please refer this blog for better understanding ARRAffinity.

Application Insights doesn’t show which instance a user is on by default. You can track this by logging the instance ID (using the WEBSITE_INSTANCE_ID variable) in your telemetry.

Refer this MSDoc to know about above environment variable.

Here's the sample code :

var instanceId = Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID");
TelemetryClient.TrackEvent("UserSessionTracking", new Dictionary<string, string>
{
{ "UserId", userId },
{ "InstanceId", instanceId }
});
`

This lets you filter and view data based on the instance the user was on.

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (1): this blog
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Andrew
Posted by: Sirra Sneha