Question

I know this is probably something really stupid, but I've been searching google for 2 hours to figure this out.

I have a new test Azure app that I would like to debug in Visual Studio. If I set the startup project to the Web Role (MVC) project, I can hit breakpoints in VS, but it's not running in the emulator so all of my Azure calls fail.

If I set the startup project to the Cloud project, the emulator starts, then Visual Studio ends debugging and my web role is never launched.

What am I missing here? How do I launch my web page and still have access to the emulator?

(Side note.. why isn't there a Visual Studio 2012 tag??)

Was it helpful?

Solution 3

I un-installed and re-installed all my Azure SDK's, to no avail.

This link

Debugging Azure: Error attaching the debugger to the IIS worker proccess

told me where to look for the error that was causing it to fail, which led me to this link:

http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/07fe087e-4ac3-4c4f-bd62-4fccff4afd45

The ACL on the Windows Azure registry entries were not in "canonical order".  
All you have to do is fix that and this error goes away.  
These are the steps I took:

1.)  regedit, navigate to HKLM\Software\Microsoft\Windows\Windows Azure

2.)  Right-click, choose "Permissions".  You will get a warning that the 
     security information is incorrect and you get a button labelled "Re-Order". 
     Click this and the security information then shows up as normal.

3.) Follow the same steps for the Windows Azure AppFabric and Windows Azure Emulator 
    registry entries in the list after the Windows Azure entry.

Problem Solved!

Note that I found the key under HKLM\Software\Microsoft\Windows Azure, not under Windows\Windows Azure.

OTHER TIPS

Although this doesn't answer your question directly, I always make sure that my projects run outside of the emulator. If for nothing else, this just greatly improves the efficiency of your development.

To avoid the issue of the Azure calls failing, one very basic practice you can use is to use a Dependency Injection framework (such as Unity or others) and create a LocalConfigurationManager and a AzureConfigurationManager which both implement some interface like IConfigurationManager, then if your code needs to ask Azure for an instance number, or config setting, etc... the LocalConfigurationManager can just return a hard coded number/setting, and the real AzureConfigurationManager will actually call Azure.

The trick is to use the Web.Debug.Config and Web.Prod.Config files (or perhaps just use the #IF DEBUG C# precompiler statement) to change the implementation depending on the build config.

I have just created a Azure project with an MVC Web Role and I was able to hit a breakpoint in a controller action without any issues. Some things to check:

  1. Do you have a WebRole.cs file in your MVC project containing a class derived from RoleEntryPoint?
  2. Is there a node in the Roles folder of the Azure project representing your MVC project?
  3. When you run the Azure project does the Compute and Storage emulator icon show up in the Notification Area of the taskbar?
  4. Does the ServiceDefinition.csdef file in your Azure project contain a Web Role node with an attribute matching your MVC project name?

WebRole name="MvcWebRole1" vmsize="Small"

As a quick test try creating a new Azure project with a MVC Web Role, add a controller with a single action that returns a view and put a breakpoint in there. Then set your Azure project as the "Startup Project". If everything is working correctly you should hit the breakpoint when you debug the Azure project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top