3
votes

I have an Azure solution that I want to debug in Visual Studio 2010. I have two MVC sites set up as Virtual Applications in a single Web Role - this structure makes sense from a cost and url standpoint. The virtual applications worker processes don't spin up automatically and therefor VS doesn't attach to it. After hitting the virtual applicaiton url (i.e. localhost/app1) in the browser, a new w3p process starts and I can manually attach to it. Just wondering if someone out there has done this before and has a tip on how to automatically attach to the process.

Related post that makes it sound like you have to do it manually: http://social.msdn.microsoft.com/Forums/uk/windowsazuredevelopment/thread/f1c5d72b-9196-480e-ace6-3c9063be79a7

2
I haven't figured out a better way, so I'm hoping somebody else comes up with an answer for you.Brian Reischl

2 Answers

0
votes

This isn't Azure specific, but you could trigger a breakpoint when your application starts:

    protected void Application_Start()
    {
        #if DEBUG
        System.Diagnostics.Debugger.Break();
        #endif

        ...
    }

And you could try to combine this with a startup task only running when you are in the emulator and that hits the url of both web applications (using wget.exe for example). This will create the w3wp process, triggering the Debugger.Break.

Resource: http://blog.smarx.com/posts/skipping-windows-azure-startup-tasks-when-running-in-the-emulator

0
votes

For working on multi-site roles, at development time, I have a separate Cloud project for each site, and use a combined one for deployment purposes only. It's not ideal, but it is easier than the whole manual-attach thing.

(For history fans, this practice originally started before the SDK added support for Local and Cloud configuration files. We used to have a Local project and a Cloud project, because otherwise we kept forgetting to switch the connection strings before deploying.)