Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I attach the debugger to an Azure web app in Visual Studio 2017?

Since Azure is being updated rather often, I have yet to find an updated guide on how to do remote Azure debugging specifically for Visual Studio 2017.

I would simply like to know how to attach to the process running on the Azure server so that I can debug my web app.

like image 698
01F0 Avatar asked Nov 01 '17 17:11

01F0


People also ask

How do I Debug Azure Web app in Visual Studio?

In Solution Explorer, right-click the web project (not the WebJob project), and click Publish. In the Profile drop-down list, select the same profile that you used in Get Started with the Azure WebJobs SDK. Click the Settings tab, and change Configuration to Debug, and then click Publish.

How do I attach a process in Visual Studio 2017 for debugging?

You can attach the Visual Studio debugger to a running process on a local or remote computer. After the process is running, select Debug > Attach to Process or press Ctrl+Alt+p in Visual Studio, and use the Attach to Process dialog to attach the debugger to the process.

How do I add a Debug point in Visual Studio?

Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.


2 Answers

If you are talking about debugging a web site or api hosted in app service or service fabric, you should try using Cloud Explorer. My experiences with it have been very good.

Its pretty simple. When you open up Cloud Explorer, it shows all subscriptions and resources available to your account(s). When opening e.g. the app services for your subscription, you deployed application will be visible. You can then simply right click and say "attach debugger", as can be seen here:

from visualstudio.com

You can add multiple accounts to visual studio, and select the one that has access to the resource.

This is a more extensive tutorial on how to use the Cloud Explorer:

https://docs.microsoft.com/en-us/azure/vs-azure-tools-resources-managing-with-cloud-explorer

like image 119
Alex AIT Avatar answered Oct 21 '22 15:10

Alex AIT


There were different ways of doing this, but I think a few of them are outdated. Anyways, this is what worked for me:

  1. Turn on Remote Debugging under Azure Portal -> Your web app -> Application Settings

  2. Attach to the process in Visual Studio 2017 -> Debug -> Attach to Process.. -> Input YourWebAppName.azurewebsites.net:4020 and hit ENTER

  3. It'll ask for credentials. My AD credentials did not work here, which brings us to step 4..

  4. Azure Portal -> Overview -> Get publish profile. It'll download the publish profile for your web site. In that file, you'll find msdeploySite, userName and userPWD. Use them for step 2.

You should now be able to see the w3wp process and attach your debugger to it.

These answers/sites helped me find the solution:

https://blogs.msdn.microsoft.com/benjaminperkins/2017/01/09/cannot-publish-to-soveriegn-cloud/

https://blogs.msdn.microsoft.com/benjaminperkins/2017/06/06/remote-debug-your-azure-app-service-2017-including-asp-net-core/

https://stackoverflow.com/a/35738995/2504659

like image 29
01F0 Avatar answered Oct 21 '22 15:10

01F0