I believe I'm running into the same issue as described in this earlier posting, but after following the "official" instructions from this Microsoft document, I'm still getting the following error when my Node.js code attempts to run as an Azure Functions trigger:
2018-02-20T20:53:43.527 [Error] Exception while executing function: Functions.NewMP3FileTrigger. mscorlib: One or more errors occurred. Error: Cannot find module 'azure-storage'
at Function.Module._resolveFilename (module.js:469:15)
This is the very first line in my code, which I believe is what's failing:
var azure = require('azure-storage');
As far as I can tell, adding the package seemed to work via these steps:
- get the contents of the package.json file from here (which looks legit).
- Using the Azure diagnostic console, placed the package.json file in the wwwroot folder.
- ran npm install
in the console window.
It ran for some time, and when it was done, there was a very sizeable node_modules now in that same folder. I did note that it generate a number of warnings like the following example, but not sure if these matter:
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
Actually surprised that I need to add any modules for Microsoft services to any Azure environment as I would have thought they would be provided by default, but there you go.
You shouldn't copy package.json
from the azure-storage-node
repository. Instead, your package.json
should simply reference azure-storage
as dependency, e.g.
{
"name": "test",
"version": "1.0.0",
"dependencies": {
"azure-storage": "^2.8.0"
}
}
After npm install
make sure that node_modules
folder contains azure-storage
.
P.S. Be sure to have a look at Storage bindings for Azure Functions, maybe you don't have to use SDK directly (depends on the use case).