Question

I will be placing an Azure website, in several regions. Then configuring the Azure Traffic Manager to distribute requests to each region.

The website needs to know which region it is running in. Is there an API available to determine this? Or, is my only choice, to define a REGION app setting, that is set appropriately for each Azure website?

Was it helpful?

Solution 2

I got a response, to my question, on the Microsoft Azure DNS and Traffic Manager forum.

The answer was:

There's no handy way currently. In the Azure Powershell, you could use Get-AzureWebsite to read the WebSpace value, which is structured as Region+"webspace".

For now it's easier to just add it to the app setting, like you suggested. We'll have the region value as an environment variable in a later release.

So, as suggested, we will just use an app setting to tell the website what region it is running in. We will switch over, to the environment variable, when it becomes available.

OTHER TIPS

I had the same question today, and found this thread. It seems that Web Apps now do include the promised environment variable showing the region in which they are deployed.

I simply used:

string region = Environment.GetEnvironmentVariable("REGION_NAME");

and it worked fine (note that it returns null when run outside Azure e.g. in Visual Studio).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top