10
votes

I'm building an application which will be run on Azure. My Visual Studio solution contains multiple Azure role projects. When debugging locally, I use the Azure compute emulator.

To start debugging, I follow these steps:

  1. I right-click on my Azure project and click Set as start up project.
  2. I press F5 to start the debugger.

What happens now is that the emulator/vs2010 launches both my web roles and worker roles, even if I'm only interested in debugging a single worker role at the moment. Often when writing some background-processing code in my worker role, I'm interested to step through that code without starting the web role, launch Internet Explorer and so on as well.

Is there a convinient way to make the debugger only launch one of the role instances and not all of them?

I'm thinking of creating a separate project in my solution of type Console Application, where I load the same assemblies as in my worker role and execute the same code.

3

3 Answers

7
votes

The emulator (similar to Azure itself) works just on the concept of a "Cloud Service". So when you launch w/ debug, its going to launch whatever is defined in your Cloud Service (.ccproj) project. This mimics Azure 100% which is why it occur, but I can definitely see where your scenario would be helpful.

Few options, based on your needs.

If you need to test azure-specifics (aka it has to run in the emulator)

  • Create a second solution file, create a new Cloud service in here, add your project. I like this option because the projects/roles themselves remain untouched.

  • What Stuart suggested before me, create a second Cloud Project, set as startup, run that.

  • Similar to above, create a second project, but don't worry about startup. You can right click on any project, go to Debug and select start w/ debugging and achieve what F5 does without binding F5 to this solution

If you dont need to test azure-specifics (ie you are just testing the role)

  • Right click on the role's project, Debug, Start with Debugging This way the whole solution remains intact and you are just testing the logic
4
votes

I think you can do this by:

  • create a new Azure Cloud Project within your solution
  • add just the one worker role to that cloud project
  • set that cloud project as your startup project

This will single out just the worker you are interested in

-3
votes

An easier solution would be to open the ServiceConfiguration.cscfg file, and set the "Instances > Count" property to "0", for all the roles that you don't want running (this only works in the compute-emulator, and NOT on the azure cloud).

That way, you keep your solution intact and your configurations safe, while just omitting them from the compute-emulator during run-time.