问题
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)?
回答1:
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:
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.
回答3:
You can use Server.MachineName to get the name of the server.
回答4:
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
回答5:
You can use RoleEnvironment.CurrentRoleInstance.Id
回答6:
Request.ServerName I believe. Just like vanilla IIS
来源:https://stackoverflow.com/questions/18094039/windows-azure-websites-get-instance-identifier