For various reasons you may have difficulty attaching your debugger to an Azure Web App. This quick blog will show you a method that may work for you if you get into this situation. I will NOT attempt to diagnose your issue in this blog so please don’t post a question asking why the normal methods don’t work for you (like right clicking your resource in Server Explorer of Visual Studio).
Ensure you have enabled debugging in the Azure Portal for your App and it is set to the correct version of Visual Studio (don’t forget to save):
Step 1. From the main menu, click on the Debug menu item and select Attach to Process …
Determine the remote debugging port from this article: Visual Studio remote debugger port assignments. For example, Visual Studio 2015 uses port 4020.
Type in the URL of your Azure Web App and add the port determined above then hit enter and a credential dialog will appear:
For the User name and Password you can download the Publish Profile and extract it from there:
Look for “userName” and “userPWD” in that file. Note when you enter the user name you will need to also include the domain. For example: if the username is ‘$constowebapp’ when you enter it in the credential dialog it should be entered like this ‘$contosowebapp\$contosowebapp’.
Now that you are authenticated choose the w3wp.exe process (Standard .NET app):
For a .NET core app you will want to ensure you choose Managed(v4.6, v4.5, v4.0) code and then the name of the Core app (not w3wp.exe):
I know this was a quick and dirty blog but let me know if this helped you out. Again… My intent is not to troubleshoot your connection issues (firewall could be in the way, invalid or outdated publish profile could be associated with your app… The list goes on and on) but to get you unblocked so you can debug!