how to include the azure sdk for azure nodejs func

2019-06-02 04:10发布

问题:

I'm trying to create an azure function using typescript / nodejs. My function needs to write to BlobService, so for this I need to install the sdk.

I found I have to run 'npm install' in the function app's console (this link https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node), however, I get this error

D:\home\site\wwwroot> WARN hack2017@1.0.0 No repository field.
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "D:\\Program Files (x86)\\nodejs\\6.5.0\\node.exe" "D:\\Program Files (x86)\\npm\\3.10.3\\node_modules\\npm\\bin\\npm-cli.js" "install" "azure-asm-storage"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! path D:\home\site\wwwroot\node_modules\.staging\lodash-92db4caf
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir

npm ERR! Error: EPERM: operation not permitted, scandir 'D:\home\site\wwwroot\node_modules\.staging\lodash-92db4caf'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, scandir 'D:\home\site\wwwroot\node_modules\.staging\lodash-92db4caf'
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'D:\\home\\site\\wwwroot\\node_modules\\.staging\\lodash-92db4caf' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\home\site\wwwroot\npm-debug.log

In the npm-debug.log I see this error

30798 error tar.unpack untar error D:\local\AppData\npm-cache\azure\2.0.0-preview\package.tgz

I have tried to delete node_modules folder, I have trimmed package.json to include only a single package, and still I get the same error each time.

Any suggestions of what I might be doing wrong ?

回答1:

I was able to install the module azure-storage via Kudu under the home folder using "npm install azure-storage", then just copied the whole node_modules to the "home\site\wwwroot" folder there. My function seems to take a bit longer to load after that, but there is no more complaint about not finding that module. I am using a standard App Service plan, not Consumption plan.