JavaScriptServices icon indicating copy to clipboard operation
JavaScriptServices copied to clipboard

Deploying web app with NodeServices to Azure

Open jcmontx opened this issue 9 years ago • 7 comments

I'm trying to use NodeServices. Everything works just fine locally, but when I deploy (using Azure Continuous Delivery) doesn't work. I get this exception:

EDIT: I'm hosting in an Azure App Service.

   at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.<InvokeExportAsync>d__7`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.<InvokeExportAsync>d__13`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.<InvokeExportWithPossibleRetryAsync>d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Autocosmos.Porter.Web.Controllers.InformacionUsuarioController.<DescargarDossier>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Autocosmos.Porter.Web.Middlewares.ExceptionHandlerMiddleware.<Invoke>d__3.MoveNext()

This is my package.json:

{
  "name": "myappname",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "jsreport-core": "^1.3.1",
    "jsreport-phantom-pdf": "^1.4.4",
    "jsreport-jsrender": "^1.0.2"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

I first thought it was that node packages weren't restoring correctly. So I configured it in the build process:

image

But that didn't fix it. What am I missing here?

Maybe I should commit my node_modules? That definitely doesn't feel right.

jcmontx avatar Aug 08 '17 17:08 jcmontx

Anybody?

jcmontx avatar Aug 15 '17 15:08 jcmontx

Did you found a solution?

hdesouky avatar Aug 21 '17 00:08 hdesouky

I modified the csproj to actually publish the node_modules and my js files. It deployed them but I couldn't make it work in production. I think it has to do with jsreports package. I will continue trying.

El 20 ago. 2017 9:07 p. m., "Hesham Desouky" [email protected] escribió:

Did you found a solution?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aspnet/JavaScriptServices/issues/1177#issuecomment-323620700, or mute the thread https://github.com/notifications/unsubscribe-auth/AKIBC4uLWGfzKcDJ3P75N1SNAV-ZZAo5ks5saMoqgaJpZM4OxFVm .

jcmontx avatar Aug 21 '17 00:08 jcmontx

@jcmontx I managed to make a deploy on Azure VM server, but also needed node_modules to be copied. But strangely enough, locally on my machine I manage to have deployed site and run thru IIS7.

According to your error, I guess, you are missing NODEJS on the server where it is deployed. Remember that NodeJs is the one doing the JavaScript rendering.

theCuriousOne avatar Aug 24 '17 12:08 theCuriousOne

@jcmontx I also think this must be something to do with your jsreports packages. If you just create a new SPA app (e.g., dotnet new angular) and then deploy to Azure using Continuous Deployment, without changing any config settings at all, it will deploy and run correctly.

@theCuriousOne Azure runs ASP.NET Core apps in an environment where Node is available, so there isn't any problem with that for server-side prerendering.

Since I've verified that a clean new project deploys and runs correctly via Continuous Delivery, I'll mark this as closed. However, if anyone can repro a problem, could you please post a new issue with repro steps based on starting with a new project? Thanks.

SteveSandersonMS avatar Aug 24 '17 23:08 SteveSandersonMS

Just to add for future reference (maybe someone has stumbled upon). Make sure that you have set the ASPNETCORE_ENVIRONMENT=Production otherwise the app will search for the webpack middleware for the hot-module reloading (and you do not need that on production). If you do not have access to the machine to set this, then I suggest added to the webconfig file if you deploy to IIS more details here

<environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables>

theCuriousOne avatar Aug 25 '17 08:08 theCuriousOne

see https://github.com/aspnet/JavaScriptServices/issues/1377

gismountains avatar Nov 07 '17 21:11 gismountains