我习惯在 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
.
有人可以帮我吗?
非常感谢。
经过长时间的研究和微软工程师的帮助https://github.com/caroe2014这是三个步骤的最终答案:
1)启动.cs
services.AddNodeServices(options =>
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
options.ProjectPath = Path.GetFullPath("/home/site/wwwroot");
}
}
);
2)我发现容器中不存在 Node,因此在启动应用程序本身之前需要有一个脚本来安装和启动它。所以我有这个开始1.cs file:
#!/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"
其中 Web.Identity.dll 是我的应用程序的 dll。
3) 设置启动命令为/home/site/wwwroot/start1.sh(在 Azure 门户 - 应用服务配置 - 或 Azure DevOps 上)。
就这样。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)