1 out of 9 rated this helpful - Rate this topic

Debugging a Cloud Service in Visual Studio

The Windows Azure compute emulator is a software emulation of the Windows Azure Compute service that runs in your local environment so that you can test and debug your Windows Azure application before you deploy it to Windows Azure. The compute emulator handles the lifecycle of your role instances, as well as providing access to simulated resources such as local storage resources. When you debug or run your service from Visual Studio, Visual Studio automatically starts the compute emulator as a background application and then deploys your service to the compute emulator. You can use the compute emulator to view your service when it runs in the local environment.

noteNote
When you publish a cloud service from Visual Studio, you can enable IntelliTrace for any roles in that service that target the .NET Framework 4 or the .NET Framework 4.5. With IntelliTrace, you can examine events that occurred in a role instance in the past, and reproduce the context at that time. For more information, see Debugging a Published Cloud Service with IntelliTrace and Visual Studio and Debugging With IntelliTrace.

To Debug Your Cloud Service

  1. To debug your application, on the menu bar choose Debug, Debug.

    noteNote
    If you do not want to debug, you can choose Start without Debugging to run the application in the local development environment without debugging. If you run without debugging, the application deployment continues to run until you explicitly stop it.

  2. To display the compute emulator user interface, open the shortcut menu for the Windows Azure icon in the notification area and then choose Show Compute Emulator UI.

    The left pane of the compute emulator UI shows the services currently deployed to the compute emulator and the role instances that each service is running. You can select the service or roles to display lifecycle, logging, and diagnostic information in the right pane. If you put the focus in the top margin of an included window, it expands to fill the right pane.

  3. To debug your application, you can step through the application using the commands on the Debug menu, as well as set breakpoints in your code. As you step through the application in the debugger, the panes are updated with the current status of the application. When you stop debugging, the application deployment is deleted.

If your application includes a web role and you have set the Startup action property to start the web browser, Visual Studio starts your web application in the browser.

If you change the number of instances of a role in the service configuration, you must stop your Windows Azure application, and then restart debugging so that you can debug these new instances of the role.

noteNote
When you stop running or debugging your application, the local compute emulator and storage emulator are not stopped. You must stop them explicitly from the notification area.

Native Code Debugging

By default, Web and worker roles are debugged using the managed debugger.

To turn on native code debugging in a Web role, open the shortcut menu for the Web role project in Solution Explorer, and then choose Properties. In the property pages for the Web role project, select the Web property page, and select the Native Code check box.

noteNote
Mixed mode (both native and managed) debugging is supported only on 32-bit operating systems. On 64-bit operating systems, Web roles run as 64-bit processes, and you must select either the ASP.NET debugger or the Native Code debugger.

To turn on native code debugging in a worker role, open the shortcut menu for the worker role project name in Solution Explorer, and then choose Properties. In the property pages for the worker role project, select the Debug tab and select the Enable unmanaged code debugging check box.

noteNote
Mixed mode (both native and managed) debugging is supported on 32-bit operating systems, and on 64-bit operating systems for roles that target the .NET Framework 4. To debug in mixed mode, on the menu bar, choose Project, <ProjectName> Properties. On the Debug tab, select Enable unmanaged code debugging.

On 64-bit operating systems, worker roles that target the .NET Framework 3.5 cannot be debugged in mixed mode. To enable the native debugger only in this situation, select Enable unmanaged code debugging.

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.
facebook page visit twitter rss feed newsletter