Debug .Net Core in Azure App Service from Visual Studio

esalcedoo

Elena Salcedo

Posted on October 10, 2019

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.

💖 💪 🙅 🚩
esalcedoo
Elena Salcedo

Posted on October 10, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related