in Development

NodeJS Issues with Azure Website Git Publish Automation

There are several ways to deploy an application to an Azure web app, some of which include deploying via FTP, using the “publish” feature in Visual Studio, and local Git deployments.  While I figured-out the first two methods pretty easily, the third option gave me some issues.

To test deploying via Git, I created a new Angular application in Visual Studio 2017 as my test web site.  Although a bit outdated, I was able use this how-to guide to figure-out how to specify that I wanted to use Git for deployment and specify my newly created Azure web app as my remote Git repository.

False Positives… Deployment Fails

The issue came when I made a change to my Angular web site and attempted to push my changes to the remote repository.   Visual Studio’s Team Explorer said the sync was successful, but I didn’t see my changes after refreshing my browser window about 3 million times.

Finding Deployment Error Details

To view the deployment error, I opened the App Service details in the Azure Dashboard, then navigated to DEPLOYMENT > Deployment Options.   Ah-ha!  Indications of an error!

Clicking on the error shown above opens a deployment details screen where the deployment log file can be viewed.  The log file gives a more verbose error, but still not super helpful to an Azure newbie like myself.  About all I could tell is that the Node Package Manager was not happy:

npm ERR! Windows_NT 10.0.14393  
npm ERR! argv "D:\\Program Files (x86)\\nodejs\\6.9.1\\node.exe" "D:\\Program Files (x86)\\npm\\3.10.8\\node_modules\\npm\\bin\\npm-cli.js" "install"  
npm ERR! node v6.9.1  
npm ERR! npm v3.10.8  
npm ERR! code EBADPLATFORM
   
npm ERR! notsup Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})  
npm ERR! notsup Valid OS: darwin  
npm ERR! notsup Valid Arch: any  
npm ERR! notsup Actual OS: win32  
npm ERR! notsup Actual Arch: ia32 
  
npm ERR! Please include the following file with any support request:  
npm ERR! D:\home\site\repository\Module2Lab2\npm-debug.log

The Problem

Long-story-short, the issue was that the version of Node.js on my local PC was much newer than that on the Azure server.

Eventually learning that I needed to specify a newer version of Node.js on the Azure server, I had a few more problems…  How does one go about determining which version of Node.js an Azure web application will use?  Which versions are installed on the server to choose from?

The Solution

Changing the Default Node Version

In the Azure web app’s Application settings, the version of Node.js that will be used by the IIS server is defined in the variable WEBSITE_NODE_DEFAULT_VERSION.  The version was set to 6.9.1 but the Node.js version on my local PC was 8.9.4.   (Typing node -v at the command prompt in Visual Studio displays the Node.js version, if it’s installed.)

I thought that simply updating the WEBSITE_NODE_DEFAULT_VERSION in the application settings would’ve fixed my issue, but it only seemed to make things worse!   The issue was that I had no idea what versions of Node.js were installed on the server, so I didn’t know which versions I could use.

Determining Installed Versions of Node.js

To determine the versions of Node.js installed on an Azure web app server, visit the Kudu service that parallels your Azure web site.   The Kudu site is available by adding ‘.scm.’ into your Azure web site’s URL:

https://{sitename}.scm.azurewebsites.net/api/diagnostics/runtime

 

On the server I was using, Node.js v8.9.3 was the latest installed version, which explains why things blew-up when I specified v8.9.4 in the application settings.

Problem Solved

Upon updating the WEBSITE_NODE_DEFAULT_VERSION file in the application settings to version 8.9.3 and then redeploying my application, I can now successfully deploy using Git as my remote repository.

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.