Azure app breaks when updating Node version - azure

I have upgraded the Node.js version to 8.8.1, and updated this in the process environmental variables, iisnode.yml, Web.config and package.json.
Nonetheless, requests going to the app now get rejected with the following error:
The iisnode module is unable to start the node.exe process. Make sure
the node.exe executable is available at the location specified in the
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config>system.webServer/iisnode/#nodeProcessCommandLine
element of web.config. By default node.exe is expected in one of the
directories listed in the PATH environment variable.
I tried to update the file path in Kudu to reflect the path to the node.exe I'm interested in ("D:\Program Files (x86)\nodejs\8.1.1\node.exe"), but got an error saying I was not authorized to do this.
The relevant files:
iisnode.yml:
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.1.1\node.exe"
loggingEnabled: true
devErrorsEnabled: true
Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<!--<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"/>-->
<!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"
loggingEnabled="true"
devErrorsEnabled="true"
nodeProcessCommandLine="D:\Program Files (x86)\nodejs\8.8.1\node.exe --debug"/>
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
<!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below.
Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
<add name="NtvsDebugProxy" path="ntvs-debug-proxy/blablabla" verb="*" resourceType="Unspecified"
type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true">
<match url="^ntvs-debug-proxy/.*"/>
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="index.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
<system.web>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
</system.web>
</configuration>

In iisnode.yml, you have nodeProcessCommandLine pointing to 8.1.1 instead of 8.8.1. Maybe that's just it?

Related

How to deploy express-gateway on azure using app service

Created express-gateway application and now I am trying to deploy on azure and for that created Azure App Service, once app service created than use of Github deployment process, deployed code on app service and now when I trying to access app service on browser than I am getting 500.1001 error and on log message is like that iisnode was unable to establish named pipe connection to the node.exe process
Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
http://go.microsoft.com/fwlink/?LinkId=290972
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"/>
<!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
<!--<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"
loggingEnabled="true"
devErrorsEnabled="true"
nodeProcessCommandLine="node.exe --debug"/>-->
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
<!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below.
Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
<!--<add name="NtvsDebugProxy" path="ntvs-debug-proxy/f45f6d32-816b-47f0-8bfa-47f7930108a4" verb="*" resourceType="Unspecified"
type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>-->
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
<!--<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true">
<match url="^ntvs-debug-proxy/.*"/>
</rule>-->
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
<!--<system.web>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
</system.web>-->
</configuration>
Server.js
require('dotenv').config();
var request = require('request');
const path = require('path');
const gateway = require('express-gateway');
gateway()
.load(path.join(__dirname, 'config'))
.run();
gateway.config.yml
http:
port: 8080
admin:
port: 9876
host: localhost
apiEndpoints:
api:
host: localhost
paths: '/ip'
serviceEndpoints:
httpbin:
url: 'https://httpbin.org'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
default:
apiEndpoints:
- api
policies:
# Uncomment `key-auth:` when instructed to in the Getting Started guide.
# - key-auth:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true

iisnode: Publish an application inside an existing one

I'm trying to run two node applications, one inside another in IIS to have the proper rote:
http://server/node1
http://server/node1/node2
I have this scenario in my IIS:
Default Web Site
- node1
- node2
The struggle is that the first application node (node1) works fine, but the second keep giving me Status Code 500, however when I deploy it outsite the virtual directory (node1) works, like this:
Default Web Site
- node1
- node2
This is the web.config that I'm using:
<configuration>
<appSettings>
<!-- for node1 -->
<add key="DEPLOY_PATH" value="/node1" />
<!-- for node2 -->
<add key="DEPLOY_PATH" value="/node1/node2" />
</appSettings>
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="rewrite">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
<iisnode maxNamedPipeConnectionRetry="1000" namedPipeConnectionRetryDelay="25000" />
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
I couldn't find anything on the web about it, or similar work. I want to know why the node2 application doesn't work when deployed inside node1.

Azure node.js not receiving POST requests

I have an app that works locally but when I deploy it to azure POST requests receive a 404 response. Various answers suggest that I need to edit my web.config but I don't see what needs to be changed.
If it's relevant: My POSTs are to a path called /receive on the server, which should be handled by server.js
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
http://go.microsoft.com/fwlink/?LinkId=290972
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<iisnode watchedFiles="web.config;*.js" />
<!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
<!--<iisnode watchedFiles="web.config;*.js"
loggingEnabled="true"
devErrorsEnabled="true"
nodeProcessCommandLine="node.exe --debug"/>-->
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
<!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below.
Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
<!--<add name="NtvsDebugProxy" path="ntvs-debug-proxy/eee3ec35-9835-494f-a07c-dc2f85619df0" verb="*" resourceType="Unspecified"
type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>-->
</handlers>
<rewrite>
<rules>
<clear />
<!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
<!--<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true">
<match url="^ntvs-debug-proxy/.*"/>
</rule>-->
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
<!--<system.web>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
</system.web>-->
</configuration>
I tested your web.config file in my test node.js application, everything worked fine on my side. It should be any other reason which caused your issue. Could you kindly provide more info about your application, e.g. how you deploy to Azure Web Apps, what's your structure and any key code snippet related to the post functionality. These may help communities to detect the queston.
Meanwhile, you can try to leverage Log Stream tool to trace the all the info and stdout of your application while the Azure App is running.
You can login on your Azure Portal, navigate to Azure Apps blade, click Diagnostics Logs => Enable Application Logging (Filesystem), and then click Log stream to open the tool.

Path to use in web.config when deploying Meteorjs

Trying to deploy a meteorjs app to Azure, everything looks configured correctly except I'm not sure what to point to:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I do not have a server.js. I am deploying this from nitrous.io, where the app works as expected. Do I need to add a server.js file, and if so, what should be the content? Otherwise, what file is appropriate to point to?
Builded Meteor Application on output has main.js in root folder of your application, you should point your web server onto this file.
In rewrite rule use regular expression:
<match url="^(.*)$" ignoreCase="false" />
So your config file will be:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="main.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="^(.*)$" ignoreCase="false" />
<action type="Rewrite" url="main.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Also do not forget to set ENV variables for builded Meteor: MONGO_URL, ROOT_URL (domain with protocol, like: http://my.site), MAIL_URL, etc.

Running Keystone.js with IISnode

I'm fairly new to both Keystone and IISnode so bear with me. I've succesfully been able to run express projects with IISnode and I can run keystone.js projects with node but merging the two has been difficult. When I run the ETW traces alongside I get a "iisnode scheduled a retry of a named pipe connection to the node.exe process" multiple times before I shut it down. I've tried hooking iisnode directly to the keystone index.js file (see below from the web.config) and also to the keystone.js file at the root of the project.
<handlers>
<add name="iisnode" path="node_modules/keystone/index.js" verb="*" modules="iisnode" />
</handlers>
My hunch is that I need to hook it up to the keystone.js file as you normally do to start up the project but you typically need to add a 'keystone' parameter alongside which I'm not quite sure how I can do this with iisnode. Can anyone help me out?
The web.config handler path should be set to your application's entry point, and not node_modules\keystone\index.js. If you used the keystone Yoeman generator, the entry point is the keystone.js file in the root folder of your app.
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="keystone.js" verb="*" modules="iisnode" />
</handlers>
...
</system.webServer>
</configuration>
I have more detail instruction of how to setup keystone.js at IIS.
http://www.dakehe.info/blog/post/deploy-keystonejs-node-cms-at-iis
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="keystone.js" verb="*" modules="iisnode" />
</handlers>
<defaultDocument enabled="true">
<files>
<add value="keystone.js" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Catch All">
<match url="/*" />
<conditions>
<add input="{PATH_INFO}" pattern=".+\.js\/debug\/?" negate="true" />
</conditions>
<action type="Rewrite" url="keystone.js" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
<iisnode node_env="production" loggingEnabled="true" debuggingEnabled="true" devErrorsEnabled="true" />
</system.webServer>
</configuration>

Resources