I have a WebApp with a name like myapp.azurewebsites.net and also have a failover with the name myapp-failover.azurewebsites.net. It uses a DNS and Traffic Manager so the site is actually www.mysite.com.
I wan't to check if I am running on the main site or failover and the easiest way would be to check the myapp.azurewebsites.net name if possible. Is it possible to get this?
There are a number of Environment Variables that will help you identify which machine instance you are running on as well as which region you are running in. The easiest way to identify them is to log into the Kudu Console for the site from https://myapp.scm.azurewebsites.net/Env (this uses OAuth so if you're already logged into the portal, you'll pass right through).
You will see:
REGION_NAME
- The name of the region the site is hosted inWEBSITE_INSTANCE_ID
- The ARR Affinity Cookie for the siteWEBSITE_SITE_NAME
- the site name (domain prefix)WEBSITE_HOSTNAME
- the hostname for the siteand much much more!
EDIT
If you are using Node.js or PHP you can follow these instructions here to access those variables via the respective language Environment Variable retrieval mechanism.
If you're using .NET, you can treat them like an App Setting: