Windows Azure Websites - Get Instance Identifier

我们两清 提交于 2019-12-23 07:03:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!