Azure Linux Web 应用程序上的 ASP.NET Core NodeServices

Ric*_*fke 2 azure azure-web-app-service asp.net-core nodeservices

我习惯在 Windows 上发布 Azure WebApps,但现在我尝试将 ASP.NET Core 3(带有 NodeServices)部署到 Linux WebApp,并且收到以下错误消息:

InvalidOperationException: Failed to start Node process. To resolve this:.

[1] 确保 Node.js 已安装并且可以在 PATH 目录之一中找到。当前 PATH 环境变量为: /opt/dotnetcore-tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/site/wwwroot确保 Node 可执行文件位于这些目录之一,或者更新您的 PATH。

在 Windows WebApps 上,我还有很多其他应用程序,一切都很好。

在 Kudu 上我输入node -v并输出为v12.13.0.

有人可以帮我吗?

非常感谢。

Ric*_*fke 5

经过长时间的研究和微软工程师https://github.com/caroe2014的帮助,这是三个步骤的最终答案:

1)启动.cs

    services.AddNodeServices(options =>
        {
          if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
          {
            options.ProjectPath = Path.GetFullPath("/home/site/wwwroot");
          }
        }
      );
Run Code Online (Sandbox Code Playgroud)

2)我发现容器中不存在 Node,因此在启动应用程序本身之前需要有一个脚本来安装和启动它。所以我有这个start1.cs文件:

#!/bin/bash

apt-get install curl
curl -sL https://deb.nodesource.com/setup_12.x | bash
apt-get install -y nodejs

set -e
export PORT=8080
export ASPNETCORE_URLS=http://*:$PORT
dotnet "Web.Identity.dll"
Run Code Online (Sandbox Code Playgroud)

其中 Web.Identity.dll 是我的应用程序的 dll。

3) 将启动命令设置为/home/site/wwwroot/start1.sh(在 Azure 门户 - 应用服务配置 - 或 Azure DevOps 上)。

就这样。