Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 381
ajbeaven Avatar asked Mar 10 '17 19:03

ajbeaven


People also ask

How do I change my Azure App Service?

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.

How are configurations in Azure App Service configured?

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.


1 Answers

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

like image 97
Stewart_R Avatar answered Sep 21 '22 22:09

Stewart_R