14
votes

What's a possible way to determine on an Azure website with multiple instances what instance is responding (some ID or other piece of unique info)?

6
Did you find a solution?Liran Brimer
No, I have decided not proceed this route as it seem to be problematic.Sean Feldman

6 Answers

19
votes

The following environment setting will have the instance id the current request is running on: WEBSITE_INSTANCE_ID.

You'll also receive this id as a cookie in the response named: ARRAffinity.

You can also use this information to get back to that specific instance, see: http://blog.amitapple.com/post/2014/03/access-specific-instance/ for more information about it.

2
votes

Microsoft Azure provides many environment variables for Azure Web Apps (formerly known as Website), including the following:

  • WEBSITE_SITE_NAME - the name of the site.

  • WEBSITE_INSTANCE_ID- the id representing the VM that the site is running on.

  • etc

    See Azure Runtime Environment by David Ebbo for more details.

1
votes

You can use Server.MachineName to get the name of the server.

0
votes

Set up InstanceInputEndpoint in configuration. This will allocate ports from the given port range for each instance, then you can visit a instance through the port.

For more information about InstanceInputEndpoint: http://msdn.microsoft.com/en-us/library/windowsazure/gg557553.aspx

-2
votes

You can use RoleEnvironment.CurrentRoleInstance.Id

-3
votes

Request.ServerName I believe. Just like vanilla IIS