Debugging Azure WebRoles with Multiple Sites

Microsoft Azure has added a cool ability to allow you to host more than one website in a WebRole.  You may know this feature better as named based virtual hosting.

Setup is pretty simple – add a new website to your solution and then add a few lines to your ServiceDefinition.csdef configuration to let Azure know what domain will map to the different sites in the WebRole.  In moving GameMarx.com and XboxIndies.com to Azure, mine looked something like:

<Sites>
  <Site name="GameMarxWeb" physicalDirectory="..\GameMarxRole">
    <Bindings>
      <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="gamemarx.local"/>
    </Bindings>
  </Site>
  <Site name="XboxIndiesWeb" physicalDirectory="..\XboxIndiesSite">
    <Bindings>
      <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="xboxindies.local" />
    </Bindings>
  </Site>
</Sites>

Before I can test either of these though, I need to edit my hosts file (located in C:\Windows\System32\drivers\etc) and add a few lines to point these domains at my local box.  Initially I tried:

127.0.0.1 gamemarx.local
127.0.0.1 xboxindies.local

I could view the sites now http://gamemarx.local:81 and http://xboxindies.local:81 it I ran without debugging, but attempting to debug would give the following error:  There was an error attaching the debugger to the IIS worker process for URL ‘http://gamemarx.com:82/’ for role instance ‘deployment(43).GameMarx_Azure.GameMarxRole_IN_0’.  Unable to start debugging on the web server. The debug request could not be processed by the server due to invalid syntax.

image

Side Note: I love the line “Click Help for more information” and no actual help button exists.  Seriously, I love it.  If I meet the developer responsible for this dialog I will be sure to share my love with them.

This error is pretty generic, and from searching Google can relate to several problem.  What is really going on is when using multiple sites in a WebRole the Azure Tools use the local IIS server to host the sites.  The failure is Visual Studio and IIS do not have the same IP for the websites.  In Azure 1.5, the hosts file should be:

127.255.0.1 gamemarx.local
127.255.0.1 xboxindies.local

This has something to do with the way Azure simulates a load balancer locally.  Maybe.  To be honest I kind of got lost in forum posts and documentation and everything blurred together.   Changing the hosts file to the above however solved the issue, and I could go to http://gamemarx.local:82 with the debugger attached.  Notice the port number was now 82 and not 81 – pretty sure this has something to do with local load balancer too.  Pretty sure.  Not really, but it works and I can debug all of the sites now.

Next, I added some more domains to the site, to use when the site is live:

<Sites>
  <Site name="GameMarxWeb" physicalDirectory="..\GameMarxRole">
    <Bindings>
      <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="gamemarx.local"/>
      <Binding name="Endpoint2" endpointName="Endpoint1" hostHeader="gamemarx.com" />
      <Binding name="Endpoint3" endpointName="Endpoint1" hostHeader="www.gamemarx.com" />
      <Binding name="Endpoint4" endpointName="Endpoint1" hostHeader="azure.gamemarx.com" />
    </Bindings>
  </Site>
  <Site name="XboxIndiesWeb" physicalDirectory="..\XboxIndiesSite">
    <Bindings>
      <Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="xboxindies.local" />
      <Binding name="Endpoint2" endpointName="Endpoint1" hostHeader="xboxindies.com" />
      <Binding name="Endpoint3" endpointName="Endpoint1" hostHeader="www.xboxindies.com" />
      <Binding name="Endpoint4" endpointName="Endpoint1" hostHeader="azure.xboxindies.com" />
    </Bindings>
  </Site>
</Sites>

The problem returned, I could run the sites but not with the debugger attached.  A similar error appeared: There was an error attaching the debugger to the IIS worker process for URL ‘http://gamemarx.com:82/’ for role instance ‘deployment(44).GameMarx_Azure.GameMarxRole_IN_0’. Unable to start debugging on the web server.  The debugger cannot connect to the remote computer.  This maybe because the remote computer does not exist or a firewall may be preventing communication to the remote computer.  Please see Help for assistance.

image

Side Note: “Please see Help for assistance” is a little better, though it assumes I know where help is.  It does sound a lot like “Please seek Help” though and the part about “this may be because the remote computer does not exist” makes me wander just what the error dialog is implying!

The problem this time seems to be the Visual Studio wants to be able to attach to all versions of the site name.  You can work around this by adding all of the aliases to the hosts file, though that’s probably not desirable since you’ll need to edit the hosts file again to connect to the live versions of the sites.  You can use  the features in Visual Studio to create a build transform file to add these lines only on Release builds, or you can just comment out the name aliases until you are ready to deploy.

Posted By Mike On Friday, September 30, 2011
Filed under azure | Comments (6)

Submit this story to DotNetKicks   

David P - Friday, October 07, 2011 2:16:49 AM

Very glad to see this post. Stupid forums are useless on this topic so far (Azure SDK 1.5 hasnt been out long, to be fair).

FYI: for some reason, I needed to use 127.255.0.0 rather than 127.255.0.1, which I thought was very strange, but whatever. I found this out by hitting F5, let the error happen, look in IIS at the generated site aliases. Select one and click Browse to see the IP it was trying to target. Then I added it in the hosts file.

Ondrej - Wednesday, November 02, 2011 10:25:15 AM

Thanks for that! I also needed 127.255.0.0, strange..

Mike - Thursday, November 03, 2011 10:28:15 AM

On a different system I needed 127.255.0.0 - I guess I have something installed on my desktop that makes 127.255.0.0 not available so it goes to 127.255.0.1.

Robert te Kaat - Thursday, April 05, 2012 9:28:59 AM

Excellent!

I've been doing the same googling excercise with less luck than you had, until I met this blogpost. 127.255.0.0 works for me. I did have to exit the emulator first (and with exit I don't mean 'shutdown compute emulator', but the complete emulator).

Anton - Tuesday, September 25, 2012 7:37:35 AM

You are a god! I've wasted way too much time trying to debug this majorly unhelpful error message. For me everything was working fine up until I added the hostHeader attribute on the bindings, then it all went to crap. 127.255.0.0 worked for me, but brilliant tip on looking into the local IIS manager to see the newly created sites to get the full details.

Suart - Thursday, January 24, 2013 5:04:35 AM

127.255.0.0 works for me too - any idea how to get port 80 or 443 as I expose/use a bunch of web/rest services and having to change port between production and test is painful.
I am currently just editing the port in IIS - but this is a pain.

Leave a comment



Your name:
 

Your email (not shown):
 
Will display your Gravatar image.

Your website (optional):



About Michael

Michael C. Neel, born 1976 in Houston, TX and now live in Knoxvile, TN. Software developer, currently .Net focused. Board member of ETNUG and organizes CodeStock, East Tennessee's annual developers conference. .Net speaker, a Microsoft ASP.NET MVP and ASPInsider. Co-Founder of FuncWorks, LLC and GameMarx.

Proud father of two amazing girls, Rachel and Hannah, and loving husband to Cicelie who inflates and pops his ego as necessary.

 Subscribe to ViNull.com |  Comments

Follow me on Twitter | Contact Me

Related Posts

Moving to Azure: Worker Roles for Nothing and Tasks for Free

If you’ve been to at least one Azure presentation you’ve probably heard Azure has two primary roles: Web Roles and Worker Roles.  Web Roles run websites, ... Read more

Moving to Azure: Static Assets

You may not have noticed, but this image came from the cloud! The next stage in migrating GameMarx.com and XboxIndies.com to Azure is moving the static ... Read more

Moving to Azure: The Database

Azure has two main services for persistent data storage for application: Azure Table Storage and SQL Azure.  The really boil down to a normal SQL ... Read more

Moving to Azure: The Plan and Start

After a conversation with my former webhost about the meaning of "Recurring Annual Discount" (we have different definitions of the word "Recurring"), ... Read more

“YoGo Burger” Postmortem - Ludum Dare #28

This past weekend was another Ludum Dare game competition, and the second one I’ve taken part in (this first you can read about here).  I also organized ... Read more

XNA 3D Primer by Michael C. Neel

XNA 3D Primer by Michael C. Neel
Buy Now: [ Amazon ] [ Wrox ]

GameMarx

CodeStock

ASPInsiders Member

ETNUG Member