Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to attach Debugger from VS 2017 to Azure app service for ASP.NET CORE 2.2.1 app

I am new to azure, I have hosted a asp.net core web api in Azure App services. I am able to browse the azure link. However I am getting some internal error while accessing the service.

To find out the error I want to debug the application by attaching to visual studio. But while attaching the debugger I am getting below error as shown in the image.

ERROR POPUP WHILE ATTACHING DEBUGGER enter image description here


Error: "Unable to find a process called dotnet with arguments .\APICore.dll. The process may still be starting, please try again."

APICore is my Web api project.

I have verified that REMOTE Debugging is enabled.

  1. Application is ASP.NET Core.

  2. Visual Studio is VS 2017 community
    edition.

like image 809
Vish Avatar asked Mar 11 '19 19:03

Vish


People also ask

How do I connect debugger to Azure App Service?

In Server Explorer, expand Azure > App Service > your resource group > your app > WebJobs > Continuous, and then right-click ContosoAdsWebJob. Click Attach Debugger. The browser automatically opens to your home page running in Azure.

How do I enable remote Debug Azure App Service?

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. Right-click on the AppService that you published in Step 8 and choose “Attach Debugger” as shown below.

How do I Debug the .NET core app?

Open the Debug view by selecting the Debugging icon on the left side menu. Select the green arrow at the top of the pane, next to . NET Core Launch (console). Other ways to start the program in debugging mode are by pressing F5 or choosing Run > Start Debugging from the menu.


4 Answers

I've had the same problem today, and this is what worked out for me:

1) Instead of attaching the debugger via Server Explorer, go to Debug > Attach to Process...

2) Set the Connection Target to your App Service url without http and with port 4022.
So, http://myappservice.azurewebsites.net would become myappservice.azurewebsites.net:4022

3) Hit the Refresh button. You will be prompted for credentials to access your App Service. Those can be found on the MSDeploy publish profile of your publish profile file:

<publishData>
  <publishProfile profileName="myappservice - Web Deploy" publishMethod="MSDeploy" 
                  publishUrl="myappservice.azurewebsites.net:443" 
                  userName="{USERNAME}" userPWD="{PASSWORD}" ...>
    <databases />
  </publishProfile>
  <publishProfile profileName="myappservice - FTP" publishMethod="FTP" ...>
    <databases />
  </publishProfile>
</publishData>

4) After the available process show up, select w3wp.exe and hit Attach

like image 130
Gabriel Rainha Avatar answered Oct 01 '22 10:10

Gabriel Rainha


Had the exact same issue, tried several things (open in Admin mode, open outbound port 4022, 'Attach debugger', 'Attach to process') but nothing worked.

Just switched from VS 2017 Community edition to Visual Studio 2019 - Enterprise edition and now it instantly works flawless:

  • Published my Azure App Service in Debug configuration
  • Attach debugger via the Cloud Explorer
  • Set the breakpoints and hit them when sending requests to the API

So perhaps switching to 2019 will solve it for you as well.

like image 45
JJuice Avatar answered Oct 01 '22 12:10

JJuice


There are few options that you can try out and see if that helps.

  • Ensure Visual Studio is opened in Administrator Mode and follow the same steps.
  • Open the Outbound ports 4022 for VS 2017 on corporate firewall.
  • You can also go through the below links in order to Remote debug the application

https://docs.microsoft.com/en-us/visualstudio/debugger/remote-debugging-azure?view=vs-2017#remote_debug_azure_app_service

like image 1
Monika Reddy Avatar answered Oct 01 '22 12:10

Monika Reddy


The answer above using a regular "Attach to Process" using creds from a publish profile downloaded from the portal worked for me. VS2019 (community and professional, multiple azure accounts, multiple machines, physical and virtual) here, and the cloud explorer "AttachDebugger" never worked. In fact it hung vstudio at "attaching to process" and had to kill VStudio from task manager to stop it.

Strange because at other companies/projects I didn't have this problem. For years I relied on debugging azure from desktop for a variety of projects. This particular software I inherited, and I expect that something in its origination or construction (there are several ..."sub optimal"... aspects to it).

like image 1
Chris Hackett Avatar answered Oct 01 '22 12:10

Chris Hackett