Azure 和 MicrosoftGraph Api 部署抛出“错误:方法不允许”

Ric*_*ero 2 javascript azure node.js azure-web-app-service microsoft-graph-api

我想在 azure 中部署一个应用程序 Web 服务,但我遇到的问题是,如果我将 microsoft graph api 添加到依赖项,当我更新 git 并继续部署时,服务器返回“错误:不允许方法”。

这是应用程序 github(它是我用来测试的一个简单的 helloWorld 应用程序):https : //github.com/ricardoGuerreroAvantica/test_azure_helloworld

这是我在部署时得到的错误日志:

Command: "D:\home\site\deployments\tools\deploy.cmd".

Handling node.js deployment.
Creating app_offline.htm
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Copying file: 'package-lock.json'
Copying file: 'package.json'
Deleting app_offline.htm
Looking for app.js/server.js under site root.
Using start-up script app.js
Generated web.config.
The package.json file does not specify node.js engine version constraints.
The node.js application will run with the default node.js version 0.10.40.
Selected npm version 1.4.28
npm WARN package.json setimmediate@1.0.5 No README data
npm WARN package.json bcrypt-pbkdf@1.0.1 No repository field.
npm WARN package.json punycode@2.1.0 punycode is also the name of a node core module.
npm WARN package.json path@0.12.7 path is also the name of a node core module.
npm WARN package.json pause@0.0.1 No repository field.
npm WARN package.json util@0.10.3 util is also the name of a node core module.
npm WARN package.json string_decoder@1.0.3 string_decoder is also the name of a node core module.
npm ERR! Error: Method Not Allowed
npm ERR!     at errorResponse (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:260:10)
npm ERR!     at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:203:12
npm ERR!     at saved (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\npm-registry-client\lib\get.js:167:7)
Failed exitCode=1, command="D:\Program Files (x86)\nodejs\0.10.40\node.exe" "D:\Program Files (x86)\npm\1.4.28\node_modules\npm\bin\npm-cli.js" install --production
npm ERR!     at Object.oncomplete (fs.js:108:15)
An error has occurred during web site deployment.
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "D:\\Program Files (x86)\\nodejs\\0.10.40\\node.exe" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "install" "--production"
npm ERR! cwd D:\home\site\wwwroot
npm ERR! node -v v0.10.40
npm ERR! npm -v 1.4.28
npm ERR! code E405
npm WARN package.json setimmediate@1.0.5 No README data\r\nnpm WARN package.json bcrypt-pbkdf@1.0.1 No repository field.\r\nnpm WARN package.json punycode@2.1.0 punycode is also the name of a node core module.\r\nnpm WARN package.json path@0.12.7 path is also the name of a node core module.\r\nnpm WARN package.json pause@0.0.1 No repository field.\r\nnpm WARN package.json util@0.10.3 util is also the name of a node core module.\r\nnpm WARN package.json string_decoder@1.0.3 string_decoder is also the name of a node core module.\r\nnpm ERR! Error: Method Not Allowed\r\nnpm ERR!     at errorResponse (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:260:10)\r\nnpm ERR!     at D:\Program Files (x86)\npm\1.4.28\node_modules\npm\lib\cache\add-named.js:203:12\r\nnpm ERR!     at saved (D:\Program Files (x86)\npm\1.4.28\node_modules\npm\node_modules\npm-registry-client\lib\get.js:167:7)\r\nnpm ERR!     at Object.oncomplete (fs.js:108:15)\r\nnpm ERR! If you need help, you may report this *entire* log,\r\nnpm ERR! including the npm and node versions, at:\r\nnpm ERR!     <http://github.com/npm/npm/issues>\r\n\r\nnpm ERR! System Windows_NT 6.2.9200\r\nnpm ERR! command "D:\\Program Files (x86)\\nodejs\\0.10.40\\node.exe" "D:\\Program Files (x86)\\npm\\1.4.28\\node_modules\\npm\\bin\\npm-cli.js" "install" "--production"\r\nnpm ERR! cwd D:\home\site\wwwroot\r\nnpm ERR! node -v v0.10.40\r\nnpm ERR! npm -v 1.4.28\r\nnpm ERR! code E405\r\nD:\Program Files (x86)\SiteExtensions\Kudu\79.11121.3655\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
Run Code Online (Sandbox Code Playgroud)

Pet*_*Pan 6

根据您的错误信息,您在0.10.40Azure WebApps的默认 node.js 版本上部署了应用程序,这导致了您的问题,因为msgraph-sdk-javascript您的应用程序依赖的包需要更高版本的 NodeJS。

随着GitHub的回购README.md说,它已经过测试v6.9.1,因此您可以通过升级Azure的Web应用程序的节点版本添加一条记录WEBSITE_NODE_DEFAULT_VERSION6.9.1Application settingsAzure上的门户网站如下面这来自我的回答对一个相似的,所以线程图形库杜NPM安装失败,你也可以参考。

在此处输入图片说明