azure64-bit.net-core

How to change Azure App Service to 64-bit


I have been having trouble making a request to my 64-bit ASP.NET Core API running on an Azure App Service. The error I get back is:

Unhandled Exception: System.BadImageFormatException: Could not load file or assembly '***.dll'. An attempt was made to load a program with an incorrect format.

I understand that this means there is a mismatch between the platform of the app (64-bit) and that of the environment it runs on. I just can't figure out how to change the App Service so it runs using 64-bit.

In the Application Settings in the Azure portal I have set Platform to 64-bit:

enter image description here

However when I check in Kudu, the runtime environment indicates that it's operating under win8-x86:

enter image description here

project.json

"buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "platform": "x64"
},

"runtimes": {
    "win10-x64": {}
}

Some questions

  1. How do I change the App Service to ensure it's running on a 64-bit platform?
  2. Does it matter that the RID is win8... when my runtimes configuration in project.json specifies win10.... Presumably x86 vs x64 matters, but does it need to be the same version of windows too ie. win8 vs win10.

Solution

  • This is now available in Azure App Service.

    Steps to deploy:

    1. Set platform to 64-bit in portal
    2. Ensure the project targets 64-bit by including the following in the csproj:
    <PropertyGroup>
      <PlatformTarget>x64</PlatformTarget>
    </PropertyGroup>
    
    1. When publishing application ensure target framework is set to win-x64. (If running dotnet publish just add -r win-x64)

    The documentation is here but (at present) it is acknowledged to be a little sparse.

    This github issue response suggests we should be able to do a framework dependent deployment and have it "just work". YMMV but that wasn't my own experience hence the runtime flag suggestion above