My service is deployed to a few different environments (multiple dev environments as well as production). The service code needs to find out the URL of the current deployment at runtime.
Is there an easy way to retrieve the external-facing URL for an Azure role? If a web role is processing a request, it's straightforward to look at the HttpContext.Current.Request and fish out the URL. But I haven't been able to find a way to do this for a worker role. You'd think there would be a way to get this from the RoleEnvironment, but the closest thing I can find (RoleEnvironment.CurrentRoleInstance.RoleInstanceEndpoints) seems to return internal IP/port information, not the external-facing DNS name.
I could always store the deployment URL in a ServiceConfiguration key (i.e. store it statically in each ServiceConfiguration.???.cscfg) but I was hoping to avoid hardcoding this in the config files. Is there any way to do this programmatically?