问题
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] 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.
On Windows WebApps I have a lot of other apps and all are fine.
On Kudu I typed node -v
and the output was v12.13.0
.
Can anybody please help me?
Thank you very much.
回答1:
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
services.AddNodeServices(options =>
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
options.ProjectPath = Path.GetFullPath("/home/site/wwwroot");
}
}
);
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"
Where Web.Identity.dll is the dll of my app.
3) Set startup command to /home/site/wwwroot/start1.sh (On Azure Portal - App service Configuration - or Azure DevOps).
That's all.
回答2:
Try to mention the path in the code, This is how NodeServices was configured in Startup.cs:
services.AddNodeServices(options =>
{
options.ProjectPath = "Path\That\Doesnt\Exist";
});
来源:https://stackoverflow.com/questions/59315050/asp-net-core-nodeservices-on-azure-linux-webapp