3

I had a working Windows Azure Web Site running my node.js app and everything was working fine. I ended up needing to run a native node.js module (fibers), which necessitated that I move to a Windows Azure Cloud Service. I used the Convert to Azure Cloud Service wizard, which created a web role that allowed me to deploy my app as a cloud service and run fibers under node. So far so good.

My app requires WebSockets, which are supported under Azure Web Sites (more or less automagically when you turn it on from the config UX). I've been fighting to get WebSockets working with the Cloud Service for a few days now, and I have determined that my problem is that the version of iisnode that runs by default in a Cloud Service is too old to support node.js WebSockets in the normal way. The Cloud Service installs iisnode version 1.21 and the WebSockets support in iisnode didn't show up until version 2.0 (I have no idea why the Cloud Service image uses that crusty old version of iisnode).

Note that I don't want to use a worker role and listen on a different port (which I gather is how a lot of people address this).

Unfortunately, I cannot figure out how to install a more up to date version of iisnode in my Cloud Service (I gather that it's possible to run an installer at the startup of the Cloud Service (possibly via setup_web.cmd), but that's as far as I've gotten.

Any pointers on what I need to do to get my Azure Cloud Service running a newer version of iisnode?

BobDickinson
  • 2,156
  • 21
  • 18
  • There are actually two parts to this problem. The iisnode version needs to be updated both in the "emulator" (when you run locally) and in the real Cloud Service image. These two things are managed completely differently. Luckily, the emulator update turned out to be embarrassingly straightforward. All you need to do is install the latest pre-built iisnode-dev on your local machine. Currently that is: https://github.com/downloads/WindowsAzure/iisnode/iisnode-dev-v0.2.2.msi Now if I could just figure out how to update my Cloud Service image... – BobDickinson Mar 05 '14 at 20:04

1 Answers1

4

To update the version of iisnode installed on Azure Hosted Service you need to:

  1. Download the newest x64 installer for iisnode from http://go.microsoft.com/?linkid=9784331
  2. Include that *.msi file in the package you are deploying to the Hosted Service.
  3. In your setup_web.cmd, install the new iisnode with msiexec /i iisnode-full-iis7-v0.2.7-x64.msi /passive. This must be run as admin, but then I believe setup_web.cmd already runs as admin.

Alternativelty, for a one-off installation, you can just TS to the machine and install it manually.

By the way, what is preventing you from using the native module in Windows Azure Web Sites?

Tomasz Janczuk
  • 3,220
  • 21
  • 19
  • WRT native modules on Azure Web Sites, I tried deploying my site after adding fibers (prebuilt with Windows binaries in my node_modules) - a solution that worked fine running node locally. On the Azure Web Site the code would hang at the point of any call into fibers (I expected it to fail earlier and more obviously). I then found this discussion of native module support: http://www.windowsazure.com/en-us/documentation/articles/nodejs-use-node-modules-windows-azure-apps/, which indicated pretty unequivocally that native code in node modules was not supported on Azure Web Sites. – BobDickinson Mar 05 '14 at 20:17
  • I was able to get iisnode updated using the instructions above (as a n00b, even simple instructions like 2) take a little trial and error). Now my site reports: **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 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 didn't previously have to specify the node path, and I can run node from a command shell with no issues. – BobDickinson Mar 05 '14 at 22:33
  • FWIW, a Windows Azure Cloud Service runs the 32 bit version of node by default- from \Program Files (x86)\nodejs\ - and there is no 64 bit version of node installed on the platform. – BobDickinson Mar 05 '14 at 22:56
  • I attempted the following: Installed 64-bit version of node (no joy), attempted to install 32-bit version of iisnode (installer complained that I needed to install the 64-bit version and wouldn't continue), tried setting nodeProcessCommandLine to: "node", "node.exe", and "bin\node.cmd" (all of which work from the command line), tried specifying full path to node.exe, with and without " wrapping, and also using short path (PROGRA~2) notation. This makes me thing something else is preventing iisnode from launching node.exe, but I have no idea what. – BobDickinson Mar 06 '14 at 01:58
  • It turns out this is not an iisnode issue after all. The setup_cmd for the Cloud Service copies the web.cloud.config to web.config when the site is deployed (to use cloud settings instead of local/emulator settings). This happens in \approot. There is apparently a copy of this deployment located in \sitesroot\0 where the cloud settings overwrite does NOT happen. If I edit the web.config in directory manually and use the " wrapped full path to node.exe, then all is well. Why that whole mess happens is another issue that I'm just starting to look at. – BobDickinson Mar 06 '14 at 02:38
  • Regarding support for native modules in Windows Azure Web Sites: they do work just fine as long as you deploy a precompiled version with your application that matches the bitness of the node.exe that is running in Windows Azure Web Sites (by default 32 bit despite the OS being 64 bit). You cannot rely on the Web Sites deployment logic to compile the native modules for you. As an example, create any application with a dependency on http://tjanczuk.github.io/edge, which is a native module, and deploy to Windows Azure Web Sites - it works flowlessly. – Tomasz Janczuk Mar 06 '14 at 04:50
  • Thanks @tomasz-janczuk. I might have to take another look at getting fibers to run under an Azure Web Site. What I did was include the full distribution in my node_modules (via an npm local install), which for fibers has a bin directory containing binaries for all platforms (including Win 32 and 64). But as I said, that didn't work (nor did I get any kind of diagnostic info that would have led me in a research direction). Maybe I'll go back that way if I can't get this approot \ sitesroot madness sorted out. – BobDickinson Mar 06 '14 at 07:25