如何将Azure App Service更改为64位 [英] How to change Azure App Service to 64-bit

查看:38
本文介绍了如何将Azure App Service更改为64位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直无法向运行在Azure应用服务上的64位ASP.NET Core API发出请求.我得到的错误是:

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:

未处理的异常:System.BadImageFormatException:无法加载文件或程序集***.dll.试图加载格式错误的程序.

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

我了解这意味着该应用程序的平台(64位)与其运行的环境的平台不匹配.我只是不知道如何更改App Service,以便它使用64位运行.

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.

在Azure门户的应用程序设置"中,我已将平台"设置为64位:

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

但是,当我签入Kudu时,运行时环境表明它在win8-x86下运行:

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": {}
}

一些问题

  1. 如何更改App Service以确保它在64位平台上运行?
  2. 当我在 project.json 中的运行时配置指定 win10 ... 时,RID是否为 win8 ... 无关紧要.大概x86 vs x64很重要,但是它是否也需要与Windows的版本相同.win8 vs win10.
  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.

推荐答案

Azure App Service中现已提供此功能.

This is now available in Azure App Service.

部署步骤:

  1. 在门户中将平台设置为64位
  2. 通过在csproj中包含以下内容,确保项目目标为64位:

<PropertyGroup>
  <PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

  1. 发布应用程序时,请确保将目标框架设置为win-x64.(如果运行 dotnet发布,只需添加 -r win-x64 )
  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.

github问题响应建议我们应该能够进行依赖框架的部署,并使其正常工作".YMMV,但这不是我自己的经验,因此上面的运行时标志建议

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

这篇关于如何将Azure App Service更改为64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆