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

查看:25
本文介绍了如何将 Azure 应用服务更改为 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 位)与其运行的环境不匹配.我只是不知道如何更改应用服务,使其使用 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里面check,运行环境显示是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. 如何更改应用服务以确保它在 64 位平台上运行?
  2. 当我在 project.json 中的运行时配置指定 win10... 时,RID 是否为 win8... 是否重要.大概 x86 与 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 应用服务中可用.

This is now available in Azure App Service.

部署步骤:

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

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

  1. 发布应用程序时,确保目标框架设置为 win-x64.(如果运行 dotnet publish 只需添加 -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 应用服务更改为 64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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