简体   繁体   中英

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.

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

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 eg 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:

来自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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM