Azure Linux WebApp上的ASP.NET Core核心服务 [英] ASP.NET Core NodeServices on Azure Linux WebApp

查看:82
本文介绍了Azure Linux WebApp上的ASP.NET Core核心服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经在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: 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.

[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 WebApp上,我还有很多其他应用程序,并且都很好.

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.

有人可以帮我吗?

非常感谢您.

推荐答案

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

After a long research and the assistance of Microsoft's Engineer https://github.com/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 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.

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核心服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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