When we deploy the Web App on Azure, it can greatly improve our effectiveness in fixing bugs if we are able to implement remote debugging. Visual Studio has always been known for its power, ease of use, and of course the ability to create, publish, and debug Azure-based apps. Let's take a look at how to use Visual Studio remote debugging to deploy Web apps on Azure, along with some common considerations.
Article Source: Grape Products Technology Community
Note the version of the tool
Before starting the text, let's examine the Azure SDK version and the version of Visual Studio that you are using. According to MSDN, the remote debugging features of Azure are included in Azure SDK 2.2, so make sure that you have 2.2 or newer Azure SDKs installed on your machine.
The description on MSDN is also interesting about version issues with Visual Studio. The idea is that you can already remotely debug Website on Azure using Visual Studio 2012, but Visual Studio 2013 has made a lot of improvements. Personal understanding is best to use VS2013, or newer versions.
The experimental environment in which I wrote this article was VS2015 Update3 and Azure SDK 2.9.
Principle Introduction
If we are going to use Visual Studio on machine A to debug a program that runs on another machine B, MyApp (which is not installed on machine B), we will not only deploy the MyApp program with the PDB file to machine B, Also run a debug helper msvsmon.exe on machine B. After running msvsmon.exe, Visual Studio is able to attach MyApp and use its PDB file for debugging, which is the remote debugging feature of Visual Studio. The Msvsmon.exe program must match a specific version of Visual Studio to work, so it is integrated in the Visual Studio installation package and can be found by searching in the installation directory of Visual Studio.
Remote Debugging Azure Web APP is the same as the process above, except that we need to specify the version of Visual Studio for msvsmon.exe in the cloud configuration and tell the cloud to open some of the ports required for debugging.
Let's step into the VS Remote Debug Azure App tour.
Set Deployment Credentials
When we deploy the site, we need to create this account, which can be used for both deployment and remote debugging.
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809111431590-2007239305. PNG "width=" 668 "height=" "style=" margin:0px;padding:0px;border:0px;/>
Download Publishing profile for publishing
Publishing profile is the configuration file used for publishing operations. When we want to publish a website or a Web application, we need a lot of basic information, such as where is the server? What is a user name? What is the password? Wait a minute... This information is stored in the publishing profile file, and interested friends can open this file to see the details inside.
Whether it's debugging or not, we're going to publish the app to Azure, so download publishing profile first:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809111539340-220862345. PNG "width=" 646 "height=" 175 "style=" margin:0px;padding:0px;border:0px; "/>
Allow remote debugging of Web apps
Set the remote debugging in application settings to the allowed state, and specify the version of Visual Studio that is used for remote debugging. The relevant content has been mentioned in the principle section, here to say something to note:
These two settings are time-limited and will be turned off by default after 48 hours!
The main reason for this is performance and security, so it is recommended that you turn off the remote debugging feature immediately after debugging is complete.
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809111805777-1847055935. PNG "width=" 654 "height=" "style=" margin:0px;padding:0px;border:0px; "/>
Publish a debug version of the Web App
The debugging capabilities of Visual Studio depend on the PDB files that are generated during compilation. The following setting is for the Web App to compile to the debug version and generate the corresponding PDB file when it is published. Now Visual Studio has been able to find the PDB files intelligently, so here we don't have to worry about whether the PDB files are posted to the cloud or stored locally (simple)!
First, import the publishing profile that you just downloaded:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809111923043-1314706989. PNG "width=" 657 "height=" 376 "style=" margin:0px;padding:0px;border:0px; "/>
Select the Configuration as "Debug" in Settings:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809111953684-827733698. PNG "width=" 659 "height=" 102 "style=" margin:0px;padding:0px;border:0px; "/>
Then click on the "Publish" button to publish.
Attach Remote Process
In the Attach dialog box, enter the section "http:/" in the site URL and enter the user name and password that we created at the beginning of the dialog box that pops up.
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809112047121-1053886256. PNG "width=" 669 "height=" 506 "style=" margin:0px;padding:0px;border:0px; "/>
Select "W3wp.exe" in the list of processes listed:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809112107824-1113337369. PNG "width=" 670 "height=" 141 "style=" margin:0px;padding:0px;border:0px; "/>
Click on the "Attach" button to do it.
Impatient classmates to notice, here may need to wait for a little while ...
Start the remote debugging Web App
When you see that the breakpoint you set becomes available, you can try to trigger a breakpoint.
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/139239/201608/139239-20160809112128090-1897216816. PNG "width=" 673 "height=" 94 "style=" margin:0px;padding:0px;border:0px; "/>
Well, it looks good, it's working!
Note that the actual use of the process may not be so smooth. Mainly in the attach time, may need to try several times to succeed. The speed of the debugging process is also a problem, it is still a bit slow.
In addition, debugging a WEB application often encounters a very awkward scene: Just another user is using this feature (probably testers), so don't be surprised at this point.
This article is from the "Grape City Control Technology Team Blog" blog, declined to reprint!
Remote Debugging Azure Web App