Search code examples
azureazure-web-app-serviceazure-traffic-manager

How can an Azure website determine which region it is running in?


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?


Solution

  • 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.