Please don't close this question without reading.
I have got a regular Node.js project with an index.js and a bunch of node_modules, one of which is azure-storage to download a file.. I have compressed it into .zip and trying to upload it as an Azure WebJob.. but it is failing every time.
What it does is, there is one empty directory inside my Node.js project. I have written some code which downloads a csv file from azure storage into the local directory and converts each row into an INSERT statement.
Came across a couple of threads referring to the same prob.. what I have tried is:
It's been two days and since I didn't see anyone posting a solution here, I gotta assume that no one has run into this problem yet, or maybe very few people are using Node.js + Azure WebJobs.
The good news is, I found the problem and now I have got my Node.js WebJob up and running now inside an Azure App Service. (And the bad news is I couldn't find anything in the logs I downloaded, not sure if I missed anything in the logs).
So, here's how I did it, in case anyone tumbles upon the same problem some day...
First, don't use index.js. Use run.js as the entry point to your WebJob, and in your package.json file, have the entry { ... "main": "run.js", ... }
This is pretty simple.
Where I went wrong was, I was compressing my Node.js project directory in to a .zip file and this is where all hell broke loose. Whenever I uploaded this .zip as an Azure WebJob in my App Service.. Azure tried starting it for some time and then ended with an error saying, "failed to add webjob".
Solution: Get into the Node.js project directory and "select all" files + directories inside it and then compress the selection. Instead of compressing the Node.js project directory, compress its contents :)
Then upload the compressed .zip as an Azure WebJob in your App Service and it will work like a charm!
Some additional info: This is how my Node.js project directory looked like roughly.