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:
However when I check in Kudu, the runtime environment indicates that it's operating under win8-x86:
project.json
"buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true, "platform": "x64" }, "runtimes": { "win10-x64": {} }
Some questions
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.In the Azure portal, search for and select App services and select the app that you want to move. From the left menu, select Change App Service plan. In the App Service plan dropdown, select an existing plan to move the app to.
Configure general settings. In the Azure portal, search for and select App Services, and then select your app. In the app's left menu, select Configuration > General settings. Here, you can configure some common settings for the app.
This is now available in Azure App Service.
Steps to deploy:
<PropertyGroup> <PlatformTarget>x64</PlatformTarget> </PropertyGroup>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With