Azure Remote Debugging - Network connection has been lost - azure

I have an ASP.NET MVC 5 web application/API that I am running on Azure.
I am trying to remotely debug my application by attaching a debugger in Visual Studio 2017:
However, almost immediately this error pops up and debugging is aborted:
Sometimes it hits one of my breakpoints but then immediately stops. I have tried restarting my app a number of times but this didn't seem to help.
Any ideas?

Related

Remote debug Azure web job with .NET 6 in Visual Studio 2022

I followed this tutorial to create a simple web job in Azure: https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started. The web job itself does its job, consumes the message in the queue and I see them appear in Application Insights.
However, I want to debug the function on my local machine by using the tools available in Visual Studio 2022.
I have published with following profile settings:
Next I've attached the debugger under het Hosting menu:
First thing I noticed is a message about no symbols being loaded when putting a breakpoint in the function:
When I add a message to my queue, it gets consumed by the web job but the breakpoint is never hit. I've been reading a lot of similar questions regarding a this issue but I'm not progressing any further.
In Azure Portal, I've enabled Remote debugging under Configuration > general settings
In Visual Studio 2022, I checked if the correct process is attached
Here I'm a bit confused thou, the connection target is connecting through port 4024, which is according to this document, the port for Visual Studio 2019. However, a connection target with port 4026 is not found.
What am I missing here? Am I forgetting another setting somewhere?
If have tried changing the stack setting .NET version from APS.NET V4.8 to NET 6 (LTS) but that didn't help.
Should the platform architecture match the architecture of my machine in order to get it to work? Or is this not linked in any way with the debugger?
Is there anything else that I should check or try? Because my hair is turning grey here :)
Apologies for the delay here!
It should be 4024 for both 32 and 64 bit.
See this Azure doc: Remote Debugger Ports on Microsoft Azure App Service
Typically, the error “The breakpoint will not currently be hit. No symbols have been loaded for this document.” -- This error message indicates we can start debug process and attach, but cannot set a breakpoint on any or some lines of code in the project.
Most, likely cause: Application is built without debug symbols or debug symbols are not available
Kindly try these steps:
Verify Debug Symbols are being used and published and in sync
Workaround the issue by disabling “Enable Just My Code” from the
Tools >> Options >> Debugging >> general menu in Visual Studio
Other things to narrow-down the issue:
Debug symbols must be available locally or deployed to the Azure App Service, and must match the local code you are trying to debug.
It is recommended to use Cloud Explorer over Server Explorer to
connect and debug which requires the Azure SDK.
You could optionally Manually Attach a Debugger to Azure Web Apps to troubleshoot this further or recommend this as a workaround.
(old blog, try similar steps)
Kindly verify the port (Visual Studio remote debugger port assignments ) required is open in the corporate firewall and on your local machine.
As a test, you may use tool like Wireshark/netmon, to see if the port successfully connects to the port (4024) needed by the process.

Can't publish Azure Function from Visual Studio for Mac

I am trying to publish my Azure Functions from Visual Studio for Mac (8.10.6, build 10) and it does not work.
Everything works fine when running func start (obviously running from Visual Studio does not work as my Macbook has M1 processor and that is not supported yet).
What's more, when I created new function from template, I can publish it normally. I've read that it could be because of antivirus working on machine, but I expect that if I can publish other functions then it should work fine.
When trying to publish from Visual Studio I am getting:
/usr/local/share/dotnet/sdk/5.0.302/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeploy.targets(140,5): error : Web deployment task failed. (Web Deploy experienced a connection problem with the server and had to terminate the connection. Contact your server administrator if the problem persists. Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CONNECTION_TERMINATED.)
/usr/local/share/dotnet/sdk/5.0.302/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeploy.targets(140,5): error :
/usr/local/share/dotnet/sdk/5.0.302/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeploy.targets(140,5): error : Web Deploy experienced a connection problem with the server and had to terminate the connection. Contact your server administrator if the problem persists. Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_CONNECTION_TERMINATED.
/usr/local/share/dotnet/sdk/5.0.302/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeploy.targets(140,5): error : Unexpected end of file has occurred. The following elements are not closed: results. Line 1, position 550.
Do you have any ideas why could that be?
Sounds like a firewall/access issue, check that VS is trusted and has access to connect to the internet
https://learn.microsoft.com/en-us/visualstudio/mac/install-behind-a-firewall-or-proxy-server?view=vsmac-2019

visual studio 2017 remote debugging azure api app: "The breakpoint will not currently be hit. No symbols have been loaded for this document."

I'm trying to remote debug an asp.net core 1.1 api app (targeting .net framework 4.5.2) that's running on Azure.
I attach the debugger via Server Explorer. The debugger attaches to the correct process. But any breakpoint I set has the message "The breakpoint will not currently be hit. No symbols have been loaded for this document."
All answers I've seen to such a problem assume that the modules window shows all modules loaded by my project, but in my case the modules window is empty!
I'm on VS2017 15.4.
If I remember correctly, I was previously able to remote debug the same project with version 15.2. The problem started occurring when I updated to 15.3 but I didn't pursue it at the time.
I submitted the problem on the MS forums: Can't remote debug Azure API app
and now I have received an official reply that it is indeed a bug in VS, and a fix will be available in the pending release (15.6).
They also suggested a workaround, which I tried and indeed worked: Manually Attach a Debugger to Azure Web Apps
Which involves:
Going to the web app Application settings in the Azure portal, and making sure that Remote debugging is enabled,
In the VS menu: Debug > Attach to Process..., entering the web app url with the debugging port, e.g.:
myapp.azurewebsites.net:4022
Then in the credentials that appears, entering the username & password that are available in the app's Publish Profile, which can be downloaded from the portal. If the username is $myapp, it should be entered like this:
$myappp\$myapp
Then choosing Managed(v4.6, v4.5, v4.0) code and then the name of the Core app.
Actually, I had found and unsuccessfully tried similar approaches before. The key for me was step 3. The others had suggested entering the username as .\$myapp, or myapp\$myapp. So make sure to enter it as written above.
BTW, seeing that the above blog post is from almost 2 years ago (Feb 2016), whereas the problem I'm experiencing was introduced only a few months ago, it seems to be a cure-all, and it is therefore worthwhile, for anyone who has to deal with remote debugging Azure apps, to save this information for future reference.
UPDATE:
After updating VS 2017 to version 15.5.2 the problem seems to have been fixed.
I have had the same issue with Visual Studio 2019. The fix for me was just to go in the VS menu: Debug > Attach to Process, and try to connect as describe by #Dan Z. The connection was not established, saying No connections found, but attaching a debugger from Cloud Explorer again, right after an attempt in "Debug > Attach to Process" is always successful. That is most probably a bug in VS

Azure Service Debugging hangs on attach to process how can I trouble shoot this?

I'm trying to debug a deployed Azure Worker Role. I have the service published from visual studio and confirmed it is running on my Azure dashboard. In visual studio I right click the Instance of the role (only 1 is there) and select debug. After 5+ minutes I get the process dialog box and I select the WaWorkerHost.exe process. After that nothing is happening - I have a visual studio dialog that says "A remote operation is taking longer than expected". It has been 25 minutes so far.
1) I need to be able to debug my service and I'd like to do it vs the Azure published version. How can I debug this hanging operation?
2) 30+ minutes is not reasonable to wait for a debugger to attach. Is there any way to improve the process?
To be able to debug your Azure cloud service, you first need to make sure it is built with the Debug configuration and that the remote debugger feature is enabled, then you'll be able to attach to the role from Visual Studio as if you were running it locally.
You can follow these steps to enable the debugger and attach to the service: https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-debug-cloud-services-virtual-machines/

Default MVC5 Application will not run out of debug mode in browser VS Express 2013

I have just started to develop an application in Visual Studio 2013 using MVC5. I am using the default MVC application, I have made no changes. I find that running the application works fine while in debug mode however if I Stop Debugging Shift F5 and change from on page to another or refresh my application in the browser I find that the connection to the localhost server is disconnected. I get a message Firefox can't establish a connection to the server at localhost: I have tested another application developed in Visual Studio 2012 and now running on VS2013 and it runs as expected out of debug mode. Has anybody else come across this problem. What am I doing incorrectly?
Do you have Edit and Continue enabled? (This can be found under your projects Properties -> Web, at the bottom.
When you have Edit and Continue enabled, the VS debugger attaches invasively to the web server process (IIS Express). When you stop the debugger, this kills the IIS Express process as well. If E&C is turned off, the debugger does not use an invasive attach, which lets the debugger stop without killing the attached process.

Resources