How to Debug Azure App Services Using Remote Debugging in Visual Studio

Introduction

 
Debugging is one of the key features used by every developer in any kind of development platform or language. However, to fix some critical issues, sometimes debugging has to be done for the application which is already deployed in the server.
 
We know that the process can be attached to an application to debug, but how do we do this for the application hosted in Azure? You will get an answer here, with simple steps.
 
Step 1
 
Log in to Azure Portal and go to the AppService that you wish to debug. Download the app publish profile from the overview pane using “Get publish profile” option, like shown below:
 
How To Debug Azure App Services Using Remote Debugging In Visual Studio
 
Step 2
 
Open your project in Visual Studio. Set the debug breakpoint at any line of the code you wish to debug.
 
Step 3
 
Right-click the solution and choose the “Publish” option, which will give you a screen like the one shown below. Based on the Visual Studio version you are using, the screen UI will differ.
 
How To Debug Azure App Services Using Remote Debugging In Visual Studio
 
Step 4
 
Click the “Import Profile” option. At the bottom, next to cancel, there is a settings icon. Click the settings icon to switch the mode from Publish to “Create Profile”
 
How To Debug Azure App Services Using Remote Debugging In Visual Studio
 
Step 5
 
Now click “Create Profile” at the bottom. It will open a FileDialog to select the publishing profile which you downloaded in Step 1. It will configure the AppService to be available for publishing from Visual Studio.
 
Step 6
 
By default, publishing profiles will be configured to build and publish in Release mode. However, here we are going to debug, so we need to configure the publish profile to build and publish in Debug mode. To do that, go to the settings section, as shown below:
How To Debug Azure App Services Using Remote Debugging In Visual Studio
 
Step 7
 
In the next screen, choose “Settings” from the left menu and in the configuration option, choose “Debug”, then click save.
 
How To Debug Azure App Services Using Remote Debugging In Visual Studio
 
Step 8
 
Now, click the Publish button in the Publish Wizard. Your debug build along with debugger information will be published to the Azure App Service.
 
Step 9
 
Now time to enable remote debugging. In your Visual Studio, go to View -> Server Explorer. In the server explorer, configure your Azure account, which will list all your AppServices in the account.
 
Step 10
 
Right-click on the AppService that you published in Step 8 and choose “Attach Debugger” as shown below. It will publish your app again and convert your Visual Studio in debug mode.
 
How To Debug Azure App Services Using Remote Debugging In Visual Studio
 
We are all done. If you have placed the debug breakpoint in the start-up file itself, you will get a debugging hit in the page load itself. Elsewise, the breakpoint will hit when the specific functionality is executed.
 
Once your debugging is done, you can again configure the Publish Profile as Release mode and publish again, because we cannot leave the debug mode to run in the server.
 
I hope this article helps you to debug your Azure App Service. If you have any questions/issues about this article, please let me know in the comments. 


Similar Articles