« Automating backup of a SQL Azure database to Azure Blob Storage with the help of PowerShell and Task Scheduler | Main | Creating custom Windows event logs and sources in a Windows Azure Compute startup task »



TrackBack URL for this entry:

Listed below are links to weblogs that reference Hosting a public web site and an internal services site in one Windows Azure web role:


Feed You can follow this conversation by subscribing to the comment feed for this post.


Hi Christian,
I have implented the code - but I cannot get this to work. I am getting a 404 server error when trying to connect to the WCF service from my web role.
Can you please send me some sample code ?

Neville Parakh

Hi Christian,

Would it be possible to get the code for this sample application?

Many thanks,

Christian Weyer

Sure - you guys just send me email (you can figure out my email address, I am sure).

John Dandison

Christian - this is fantastic. Really got me out of a bind. I added a couple of lines of code for discoverability of services hosted in other roles. I folded and went the extra parameter route, but I'm sure there's a LINQ query out there that could do what I was doing without that extra parameter. Essentially finding all endpoints in all roles that match the endpoint name, not just within that role.

public static void AdjustEndpointAddress(this ChannelFactory channelFactory, string roleName, string internalEndpointName)
var appService = RoleEnvironment.Roles.Single(x => x.Key == roleName);
var endpoints = appService.Value.Instances.Where(x => x.InstanceEndpoints.ContainsKey(internalEndpointName));
//var roles = RoleEnvironment.Roles.Values.Select(x => x.Instances.Select(y => y.InstanceEndpoints.Where(z => z.Key.Equals(internalEndpointName))));
//var serviceEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[internalEndpointName].IPEndpoint;
var serviceEndpoint = endpoints.First().InstanceEndpoints[internalEndpointName].IPEndpoint;
if (serviceEndpoint != null)
var serviceAddress = channelFactory.Endpoint.Address.Uri;
var serviceUrl = new Uri(String.Format("{0}://{1}:{2}{3}",
channelFactory.Endpoint.Address = new EndpointAddress(serviceUrl);

The comments to this entry are closed.

Shared items (Google Reader)