我正在使用Windows Azure移动服务的源代码控制功能来推送自定义API脚本。
我做了什么:
克隆了git仓库。 (它包含一堆目录以及一些readme.md文件,这些文件说明了行进的方向以及一些用于现有表权限的配置文件。)
添加了service/api/test.js
和service/api/test.json
文件(自定义API脚本和配置)。
已提交并将更改推送到远程。
我从git得到以下输出:
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '1cbfbd5ac1'.
remote: Running custom deployment command...
remote: Running deployment command...
remote: Handling Basic Web Site deployment.
remote: KuduSync.NET from: 'D:\home\site\repository\service' to: 'D:\home\site\wwwroot\App_Data\config\scripts'
remote: Copying file: 'api\test.js'
remote: Copying file: 'api\test.json'
remote: Missing server.js/app.js files, web.config is not generated
remote: Node.js versions available on the platform are: 0.6.17, 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.10.5, 0.10.18, 0.10.21, 0.10.24.
remote: Selected node.js version 0.10.24. Use package.json file to choose a different version.
remote: npm WARN package.json myservice@1.0.0 No repository field.
remote: npm WARN package.json myservice@1.0.0 No README data
remote: Finished successfully.
remote: Deployment successful.
现在,当我尝试通过标准API访问任何现有表时(例如,发布到
https://myservice.azure-mobile.net/tables/MyTable
),我会收到500 Internal Server Error。我认为以上输出中的这一行与此有关:
remote: Missing server.js/app.js files, web.config is not generated
但是,git仓库中从未包含任何
server.js
或app.js
,我也不知道这些文件应该包含什么,因为在文档中似乎没有提及这些文件。 最佳答案
原来,此错误消息不是罪魁祸首:
remote: Missing server.js/app.js files, web.config is not generated
像一个好的程序员一样,我已经将配置信息放置在
<PROJECT_ROOT>/shared/config.json
中。当我检查日志时,它抱怨路由配置不正确。文档暗示只有<PROJECT_ROOT>/api
包含自定义路由,因此当文档明确指出共享目录专门用于表和custom使用的共享代码时,我不知道为什么它将共享目录中的JSON文件解释为路由配置API脚本。将其从
config.json
更改为config.js
并进行必要的代码更改之后,它们又重新开始工作。我仍然收到有关缺少server.js / app.js文件的警告,但似乎没有任何影响。
结论:请勿将JSON文件添加到Azure移动服务脚本中,除非最初与脚本捆绑在一起的
readme.md
文件中指定。关于node.js - 缺少server.js/app.js文件,未生成web.config,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21743041/