如何将Azure App Service更改为64位 [英] How to change Azure App Service to 64-bit
问题描述
我一直无法向运行在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": {}
}
一些问题
- 如何更改App Service以确保它在64位平台上运行?
- 当我在
project.json
中的运行时配置指定win10 ...
时,RID是否为win8 ...
无关紧要.大概x86 vs x64很重要,但是它是否也需要与Windows的版本相同.win8 vs win10.
- How do I change the App Service to ensure it's running on a 64-bit platform?
- Does it matter that the RID is
win8...
when my runtimes configuration inproject.json
specifieswin10...
. 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.
部署步骤:
- 在门户中将平台设置为64位
- 通过在csproj中包含以下内容,确保项目目标为64位:
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
- 发布应用程序时,请确保将目标框架设置为win-x64.(如果运行
dotnet发布
,只需添加-r win-x64
)
- 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屋!