When we deploy WEB apps on Azure, how we can implement remote debugging will greatly improve our efficiency in fixing bugs. 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.
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.
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:
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.
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:
Select the Configuration as "Debug" in Settings:
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.
Select "W3wp.exe" in the list of processes listed:
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.
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.
Remote Debugging Azure Web App