My service is deployed in several different environments (several development environments, as well as in production). The service code should find out the URL of the current deployment at run time.
Is there an easy way to get the external URL for the Azure role? If the web role is processing the request, you just need to look at HttpContext.Current.Request and catch the URL. But I could not find a way to do this for a working role. You might think that this would be a way to get this from RoleEnvironment, but the closest thing I can find (RoleEnvironment.CurrentRoleInstance.RoleInstanceEndpoints) seems to return internal IP port information, not a DNS name with an external name.
I could always save the deployment URL in the ServiceConfiguration key (i.e. store it statically in every ServiceConfiguration.???.cscfg), but I was hoping to avoid hard-coding it in the configuration files. Is there any way to do this programmatically?
source
share