Azure Linux WebApp上的ASP.NET Core核心服务

编程入门 行业动态 更新时间:2024-10-27 12:40:28
本文介绍了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/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核心服务

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

发布评论

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

>www.elefans.com

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