Nodejs Azure WebJob nodejs require('util')._extend

Recently I began doing some work with Azure web jobs using nodejs modules. Everything was going great. I developed and tested my modules locally and decided to deploy to Azure. This is where things went sideways.

Azure Web Job Details

Failed Execution

It took me a while to get the module to deploy. I had to remove folders from the node_modules folders through out the dependency tree. I will talk about that in another post. But once I got the module deployed it executed, and promptly failed. Fortunately I was able to review the web job's logs to find the error. The bad news is I had no idea why it was failing.

Azure Web Job Error

The error I received indicated the extend function did not exist or was undefined.

[06/08/2015 13:47:40 > f23e1b: ERR ]
params = extend({}, uri)[06/08/2015 13:47:40 > f23e1b: ERR ] ^
[06/08/2015 13:47:40 > f23e1b: ERR ] TypeError: undefined is not a function

I decided to test my module through the Kudu console. If you are not familiar with Azure Web Site's Kudu console it is sort of a back door way manage a live Azure Web Site.

From the Kudu console I was able to run my web job. Everything ran as expected, no errors or exceptions. So I was no further along than I was before.

The more I investigated I was able to determine the error was occurring in the node request module. If you are not familiar with node and the request module it is the defacto way to make HTTP requests. It is comparable to the .NET WebRequest object. The module is used by the Azure node SDK to call the Azure API. I am using Azure storage as part of my application, so this communicating to the Azure API is a requirement.

Azure Web Job Details

The node request module is very stable and utilized by thousands of node modules and applications. So I feel pretty confident it is not the problem. So I was still stuck.

The Solution

Ultimately I was lost and really needed to get my web job running. So I decided to create a new Azure web site and redeploy my web job. This time everything worked.

So what was the difference? The only thing I can think of is web site age. web jobs work within an Azure web site. I have not utilized them that much up to this point. This was also my first experience with a web job and I was a little lazy. I deployed my web job to a web site I provisioned maybe 3 years ago. My guess is the version of node or possibly permissions used by the web job user account were not current or configured properly. Whatever the reason, a new site worked fine.

The moral of the story, when all else fails just create a new site and try again. That is one of the best parts of cloud services. You can just create a new one and redeploy without much friction or cost. Next time I run into a web site execution issue I will probably create a new site before spending too much time troubleshooting log files. Tools like Kudu can also be a big help troubleshooting issues. Web jobs are a really cool way to run background processes. I am quickly becoming a big fan. But using nodejs can create some interesting problems compared to traditional C#, it might take some time to troubleshoot some issues, but you should be able to get things going smoothly.

Share This Article With Your Friends!

We use cookies to give you the best experience possible. By continuing, we'll assume you're cool with our cookie policy.

Install Love2Dev for quick, easy access from your homescreen or start menu.

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel