Hi,
I have a simple Angular 2 template based, asp.net core website that I am deploying to an azure app service. The site runs fine locally, but deploying to app service yields the exception stack trace you see below.
it was created using the 'dotnet new angular' template.
Note: I have also tried publishing this straight from Visual Studio to the app service and it also fails to load the site in the same way. Simply getting the "Error. An error occurred while processing your request."
Any ideas on how to resolve appreciated.
Hosting environment: Production
Content root path: D:\home\site\wwwroot
Now listening on: http://127.0.0.1:22675
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://ddcb2bportal-dev.azurewebsites.net/
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
Executing action method B2BPortal.Controllers.HomeController.Index (B2BPortal) with arguments ((null)) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
Executing ViewResult, running view at path /Views/Home/Index.cshtml.
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
Azure Web Sites environment detected. Using 'D:\home\ASP.NET\DataProtection-Keys' as key repository; keys will not be encrypted at rest.
fail: Microsoft.AspNetCore.NodeServices[0]
node.js:384
fail: Microsoft.AspNetCore.NodeServices[0]
var b = process.binding('signal_watcher');
fail: Microsoft.AspNetCore.NodeServices[0]
^
fail: Microsoft.AspNetCore.NodeServices[0]
Error: No such module
fail: Microsoft.AspNetCore.NodeServices[0]
at EventEmitter.<anonymous> (node.js:384:27)
fail: Microsoft.AspNetCore.NodeServices[0]
at Object.exitWhenParentExits (D:\local\Temp\tmpF993.tmp:280:18)
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action B2BPortal.Controllers.HomeController.Index (B2BPortal) in 4629.8181ms
fail: Microsoft.AspNetCore.NodeServices[0]
at Object.<anonymous> (D:\local\Temp\tmpF993.tmp:128:24)
fail: Microsoft.AspNetCore.NodeServices[0]
at __webpack_require__ (D:\local\Temp\tmpF993.tmp:20:30)
fail: Microsoft.AspNetCore.NodeServices[0]
at Object.<anonymous> (D:\local\Temp\tmpF993.tmp:47:19)
fail: Microsoft.AspNetCore.NodeServices[0]
at __webpack_require__ (D:\local\Temp\tmpF993.tmp:20:30)
fail: Microsoft.AspNetCore.NodeServices[0]
at D:\local\Temp\tmpF993.tmp:40:18
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: The Node.js process failed to initialize:
System.InvalidOperationException: The Node.js process failed to initialize:
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 Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.<ProcessAsync>d__33.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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>d__0.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 AspNetCore._Views_Home_Index_cshtml.<ExecuteAsync>d__31.MoveNext() in /Views/Home/Index.cshtml:line 2
--- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderPageAsync>d__14.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 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderAsync>d__13.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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.<ExecuteAsync>d__18.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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeResultAsync>d__30.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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResultFilterAsync>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResultExecutedContext 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 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
fail: Microsoft.AspNetCore.NodeServices[0]
at Object.<anonymous> (D:\local\Temp\tmpF993.tmp:41:11)
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
Executing action method B2BPortal.Controllers.HomeController.Error (B2BPortal) with arguments ((null)) - ModelState is Valid
fail: Microsoft.AspNetCore.NodeServices[0]
at Module._compile (module.js:446:26)
fail: Microsoft.AspNetCore.NodeServices[0]
at Object..js (module.js:464:10)
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
Executing ViewResult, running view at path /Views/Shared/Error.cshtml.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action B2BPortal.Controllers.HomeController.Error (B2BPortal) in 316.4095ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 5532.6964ms 500 text/html; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://ddcb2bportal-dev.azurewebsites.net/dist/vendor.css?v=wBNOjKW7v9NkvHOBvaeMwwKYLmJHl7MbEQ1OnJ1LHoY
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[6]
The file /dist/vendor.css was not modified
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 15.6528ms 304 text/css
Ok, so I created a new template via 'dotnet new angular', created a new resource group, then manually created a new app service. Deployed via Visual Studio and that worked. I have compared the src code of this temporary test to the one that is failing and .Net core/SPA template wise, they are pretty much identical.
So, I think it might be something to do with the AppService itself which was created via an ARM template.
Alllrighty, sorry to trouble anyone with lodging an issue here but I have found the resolution.
In my ARM template that was creating the App Service, I was missing the following appSetting:
"WEBSITE_NODE_DEFAULT_VERSION" = "6.9.1"
Without that, I was getting the error I quoted above. Simply adding that, and all went away.
To be fair though, I did add a section in the ARM template of type 'Microsoft.Web/sites/config' but this didn't seem to help. Only until I added the above appSetting did things work as expected.
Hopefully this helps someone else.
Thanks for letting us know you got this sorted!
For anyone else reading, newly-created Azure Website app services are already configured to use a 6.x version of Node by default (as of the time of writing), which works fine without needing any manual config overrides. It must just be the special ARM template that isn't configured in this way.
I was having a similar yet slightly different issue today:
Upon getting the var b = process.binding('signal_watcher'); error with Error: No such module, I realized this is a node versioning issue.
running node --version from kudu gave: v0.10.28 which was odd...
Setting "WEBSITE_NODE_DEFAULT_VERSION" = "6.11.2" in app settings did the trick.
Hope this helps.
Most helpful comment
Alllrighty, sorry to trouble anyone with lodging an issue here but I have found the resolution.
In my ARM template that was creating the App Service, I was missing the following appSetting:
"WEBSITE_NODE_DEFAULT_VERSION" = "6.9.1"
Without that, I was getting the error I quoted above. Simply adding that, and all went away.
To be fair though, I did add a section in the ARM template of type 'Microsoft.Web/sites/config' but this didn't seem to help. Only until I added the above appSetting did things work as expected.
Hopefully this helps someone else.