How to change Azure Application Service to 64-bit

I'm having trouble sending a request to my 64-bit ASP.NET API running on Azure App Service. The error I am returning is:

Unhandled exception: System.BadImageFormatException: Failed to load file or assembly "***. Dll". An attempt was made to download a program with the wrong format.

I understand that this means that there is a mismatch between the application platform (64-bit) and the environment in which it runs. I just can't figure out how to change the application service, so it works with the 64-bit version.

In the application settings on the Azure portal, I installed the platform in 64-bit:

enter image description here

However, when I check Kudu, the runtime indicates that it works under win8-x86:

enter image description here

project.json

"buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true, "platform": "x64" }, "runtimes": { "win10-x64": {} } 

Some questions

  • How to change the application service to ensure its operation on a 64-bit platform?
  • Does it matter that RID is win8... when my runtime configuration in project.json indicates win10... Presumably, x86 vs x64 matters, but whether it is necessary to be the same version of windows, i.e. win8 vs win10.
+18
source share
4 answers

This is now available in Azure App Service.

Steps to Deploy:

  1. Set the platform to 64-bit in the portal
  2. Make sure the project targets the 64-bit version by including the following in csproj:
 <PropertyGroup> <PlatformTarget>x64</PlatformTarget> </PropertyGroup> 
  1. When publishing the application, make sure that the target platform is installed on win-x64. (If dotnet publish running, just add -r win-x64 )

The documentation is here , but (currently) it is a bit sparse.

This answer about the github problem suggests that we should be able to perform infrastructure-dependent deployments and make it β€œjust work”. YMMV, but it was not my own experience, therefore, the support flag proposed above

+1
source

TL; DR; The 64-bit core .NET core processes using the .NET runtime (unlike the .NET Framework runtime) are not yet supported by Azure, but are planned in the future.


The following are discussions held with Microsoft Azure support.

The 64-bit / 32-bit configuration on the Azure portal (shown above in my screenshot) controls the IIS w3wp.exe process. The w3wp.exe process sends requests to your main NET process. The configuration does not control the bitness of the main .NET process. This is a bit confusing, but explains why changing the Platform parameter in the screenshot above did not affect.

Based on the configuration of the PATH environment variable for the application service, dotnet.exe is mapped to 32-bit, which is "D: \ Program Files (x86) \ dotnet \ dotnet.exe". The 64-bit .NET kernel runtime is not pre-installed in applications, so it is currently unavailable.

Microsoft plans to add 64-bit support for core .NET applications running in the .NET kernel environment in Azure, but this depends on future updates to the core .NET instrumented network. They gave me an approximate internal date, but I promised that I would not publish it publicly.

The workaround they provided to me was to use the ASP.NET visual studio template (using the .net framework), rather than the ASP.NET kernel (using the .net kernel). It downloads the 64-bit .NET Framework for your main ASP.Net web application. This will require a little migration work, and I suggest that some projects may not be possible.

Fortunately, I managed to exchange for 32-bit versions of some of my dependencies, which meant that the application was running in an Azure environment. Unfortunately, this means little to those who do not, and I am sure there are many.

+12
source

If you need a 64-bit runtime, there are 4 ways to do this:

  1. Standalone Application Deployment
  2. Deploy Your Own Runtime
  3. Use the Azure Linux Application Service
  4. Use container web applications

For more information on how to do this, see the link below: https://blogs.msdn.microsoft.com/webdev/2018/01/09/64-bit-asp-net-core-on-azure-app- service./

Credits for: Glenn Condron

+10
source

The dotnet publish command generates a web.config file that IIS uses to start the dotnet process. In Kudu, in the PATH environment, the variable dotnet.exe is located in the folder D: \ Program Files (x86) \ dotnet

The solution is to replace in this file after assembly

 <aspNetCore processPath="dotnet" arguments=... 

from:

 <aspNetCore processPath="%ProgramFiles%\dotnet\dotnet" arguments=... 
0
source

Source: https://habr.com/ru/post/1015666/


All Articles