Azure Linux WebApp 上的 ASP.NET Core NodeServices

编程入门 行业动态 更新时间:2024-10-27 14:28:55
本文介绍了Azure Linux WebApp 上的 ASP.NET Core NodeServices的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I am used to publish Azure WebApps on Windows but now I am trying to deploy an ASP.NET Core 3 (with NodeServices) to a Linux WebApp and I am receiving the following error message:

InvalidOperationException:无法启动节点进程.要解决这个问题:.

[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.

[1] Ensure that Node.js is installed and can be found in one of the PATH directories. Current PATH enviroment variable is: /opt/dotnetcore-tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/site/wwwroot Make sure the Node executable is in one of those directories, or update your PATH.

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

On Windows WebApps I have a lot of other apps and all are fine.

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

On Kudu I typed node -v and the output was v12.13.0.

谁能帮帮我?

非常感谢.

推荐答案

经过长期研究和微软工程师的协助github/caroe2014 这是最终答案的三个步骤:

After a long research and the assistance of Microsoft's Engineer github/caroe2014 this is the three steps final answer:

1) Startup.cs

1) Startup.cs

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

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

2) And what I found is Node is not present in the container so it is necessary to have a script to install and start it before starting the app itself. So I have this start1.cs file:

#!/bin/bash apt-get install curl curl -sL deb.nodesource/setup_12.x | bash apt-get install -y nodejs set -e export PORT=8080 export ASPNETCORE_URLS=*:$PORT dotnet "Web.Identity.dll"

Web.Identity.dll 是我的应用程序的 dll.

Where Web.Identity.dll is the dll of my app.

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

3) Set startup command to /home/site/wwwroot/start1.sh (On Azure Portal - App service Configuration - or Azure DevOps).

就是这样.

更多推荐

Azure Linux WebApp 上的 ASP.NET Core NodeServices

本文发布于:2023-11-16 19:35:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607176.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WebApp   Linux   Azure   ASP   NodeServices

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!