2

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.

Ricardo Gaefke
  • 823
  • 1
  • 7
  • 21

2 Answers2

5

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.

Ricardo Gaefke
  • 823
  • 1
  • 7
  • 21
  • 1
    Thank you, @Ricardo . In fact, I tried the above approach, but as post-deployment scripts. I could install from SSH console, but when running from post-deployment scripts, it is throwing permission error. Will try this approach. – Explore Jan 19 '20 at 15:40
  • It worked for me... You can see the devops project here [link](https://dev.azure.com/ricardogaefke/Profile4D) – Ricardo Gaefke Jan 19 '20 at 17:37
0

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";
});
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396