Forem

Elena Salcedo
Elena Salcedo

Posted on • Originally published at Medium

2 2

Debug .Net Core in Azure App Service from Visual Studio

OK, I must confess, I said: It works on my machine.
When I uploaded my code to DEV environment.. ¡Surprise! It crashes.
After doing some test in both, my local and dev environments, checking App Insights, Google and find out nothing, I decided to attach Visual Studio debugger to the Web App (only after telling my team about it, and only because it was DEV environment).
Thus, make sure that the App Service on Azure has remote debugging enabled.
Debugging — Remote Debugging: On. Visual Studio Version: 2019
MyAppService -> Configuration -> General Settings -> Debugging

Let’s attach the debugger from Visual Studio:
Cloud Explorer -> MySubscription -> AppServices -> rightclic en MyAppService -> Attach debugger
Cloud Explorer -> MySubscription -> AppServices -> rightclic en MyAppService -> Attach debugger

Suddenly, a wild Pop Up appears on Visual Studio with something I’ve never ever seen:
Unable to attach to application ‘dotnet.exe’ (PID: 9504) using ‘mywebapp’.
Unable to attach to application ‘dotnet.exe’ (PID: 9504) using ‘mywebapp’. The 64-bit version of the Visual Studio Remote Debugger (MSVSMON.EXE) cannot be used to debug 32-bit processes or 32-bit dumps. Please use the 32-bit version instead.

It seems that I’m trying to attach a 64 bit debugger to a 32 bit process. However, my Web App is configured to run on 64 bit:
Platform Settings — Platform: 64 Bit
MyAppService -> Configuration -> General Settings -> Platform Settings

How can the process run on 32 bit? Let’s check KUDU. We now can see that the .NET Core process that runs our application is on 32 bit:
Kudu -> Process Explorer -> rightclick en dotnet.exe(PID:9504)
Kudu -> Process Explorer -> rightclick en dotnet.exe(PID:9504)

It turns out that .NET CORE 2.2 SDK available by default at the Azure App Services is for 32bits
Thus, it does not take any effect configuring the Web App in 64 bit on Azure Portal. The IIS Worker Process, even running on 64 bit, will spawn .NET Core on 32 bit (due to .NET Core is only available by default on 32 bit). So the Visual Studio Debugger we should attach is the one on 32 bit as well.
If we configure the WebApp to run on 32 bit, Visual Studio will try to attach the 32 debugger this time:
Platform Settings — Platform: 32 Bit
Azure Portal → MyWebApp -> Configuration → General Settings → Platform Settings — Platform: 32 Bit

Nevertheless, if you want to run your application in 64 bit, you can configure the hosting model as InProcess. More info here.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay