Search code examples
azureazure-role-environment

Can Windows Azure roles detect which datacenter the roles are in?


Our Windows Azure roles need to know programmatically which datacenter the roles are in.

I know a REST API ( http://msdn.microsoft.com/en-us/library/ee460806.aspx) return location property. And if I deploy to, let’s say, West US, the REST API returns West US as location property. However, if I deploy to Anywhere US, the property is Anywhere US. I would like to know which datacenter our roles are in even if location property is Anywhere US.

The reason why I ask is our roles need to download some data from Windows Azure storage. The cost of downloading data from the same datacenter is free but the that of downloading data from the different datacenter is not free.


Solution

  • It is a great question and I have talked about it couple of time with different partners. Based on my understanding when you create your service and provide where you want this service to location ("South Central US" or "Anywhere US"), this information is stored at the RDFE server specific to your service in your Azure subscription. So when you choose a fixed location such as "South Central US" or "North Central US" the service actually deployed to that location and exact location is stored however when you choose "Anywhere US", the selection to choose "South Center" or "North Central" is done internally however the selected location never updated to RDFE server related to your service.

    That's why whenever you try to get location info related to your service in your subscription over SM API or Powershell or any other way (even on Azure Portal it is listed as "Anywhere US" because the information is coming from same storage), you will get exactly what you have selected at first place during service creation.

    @Sandrino idea will work as long as you can validate your service location IP address from a given IP address range published by Windows Azure team.