Debugging a Node.js app on Azure Websites

Using and debugging a Node.js app on Azure is not the easiest thing to do since Node is fronted with IIS (IISNode). We ran across this nice article, How to debug a Node.js web app in Azure App Service, that helped out a ton, but I wanted to provide a few more clarifing details. There are 2 main points to mention.

Editing the IISNode.yml configuration file

There are many ways, but assuming this debugging is a TEMPORARY thing, and you are NOT doing it in production, we can just edit it on the server. In our case, we were using a staging deployment slot, so it was fine.

I like to use the Kudu interface for this. You can navigate to https://[your web app name] or click the link from the portal:


Once you launch Kudu, go to the Debug Console menu item and, anc click CMD. Then navigate to site\wwwroot by clicking the folders in the GUI, or by using the command window. In that folder, you will see the IISNode.yml file. Click the eidt icon (the little pencil) and you will be able to add the configuration changes needed per the article mentioned above. For reference, the changes we needed for debugging were:

loggingEnabled: true  
devErrorsEnabled: true  

Save the change, and restart your web app back in the portal.

Accessing the logs via the Azure-CLI (Node.js)

Once your logging is happening, you will need to get to them. The article talks about the many ways, we tried to use the Azure-CLI as mention by running

azure site log download [sitename]  

but is seemed to be broken. Here is what we received:

$ azure site log download [sitename]
error:   'site' is not an azure command. See 'azure help'.  
The current mode is: arm (Azure Resource Manager).  

What? Is the Azure Documentation wrong? (again!). Do I have an old version of the CLI? Nope. Turns out the Azure-CLI has different modes of operation. This was new to me. Notice the error stating "The current mode is: arm (Azure Resource Manager)."

To use the azure site command, swich the mode to the Azure Service Management (asm) mode:

azure config mode asm  

You can then use the azure site command to perform the operations described in the article. I personally liked the Live Stream (tail) operation to get a steaming output from your webapp:

azure site log tail [sitename]  

If you are using deployment slots (like we were), you can get access to your slot by using the --slot argument.

azure site log tail [sitename] --slot staging  

Hope this helps!