网站部署到Azure keystone.js时出错

我正在尝试将在Node.js中构build的普通keystone.js初学者应用程序部署到Azure网站的Shared Tier。

部署后出现错误

The page cannot be displayed because an internal server error has occurred.

我认为这可能是因为主服务器文件被称为keystone.js所以我把它重命名为index.js 。 这没有解决它。

接下来,我认为这可能是一个问题,因为keystone默认为端口3000,所以我在我的index.js文件中添加了端口信息。 这里是:

 // Simulate config options from your production environment by // customising the .env file in your project's root folder. require('dotenv').load(); // Require keystone var keystone = require('keystone'); // Initialise Keystone with your project's configuration. // See http://keystonejs.com/guide/config for available options // and documentation. keystone.init({ 'name': 'Magic Site', 'brand': 'Magic Site', 'less': 'public', 'static': 'public', 'favicon': 'public/favicon.ico', 'views': 'templates/views', 'view engine': 'jade', 'mongo': "redacted", 'port': process.env.PORT || 1337, 'auto update': true, 'session': true, 'auth': true, 'user model': 'User', 'cookie secret': 'redacted' }); // Load your project's Models keystone.import('models'); // Setup common locals for your templates. The following are required for the // bundled templates and layouts. Any runtime locals (that should be set uniquely // for each request) should be added to ./routes/middleware.js keystone.set('locals', { _: require('underscore'), env: keystone.get('env'), utils: keystone.utils, editable: keystone.content.editable }); // Load your project's Routes keystone.set('routes', require('./routes')); // Setup common locals for your emails. The following are required by Keystone's // default email templates, you may remove them if you're using your own. // Configure the navigation bar in Keystone's Admin UI keystone.set('nav', { 'posts': ['posts', 'post-categories'], 'galleries': 'galleries', 'enquiries': 'enquiries', 'users': 'users' }); // Start Keystone to connect to your database and initialise the web server keystone.start(); 

仍然没有运气。 但是,这在我的本地机器上效果很好,不在Azure中。 有任何想法吗?

更新:我更新我的主要服务器文件被命名为“server.js”。 我做了一些挖掘,看着Azure中的部署日志,发现这个:

 Command: "D:\home\site\deployments\tools\deploy.cmd" Handling node.js deployment. KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot' Deleting file: 'index.js' Copying file: 'package.json' Copying file: 'server.js' Using start-up script server.js from package.json. Generated web.config. Node.js versions available on the platform are: 0.6.17, 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.8.27, 0.10.5, 0.10.18, 0.10.21, 0.10.24, 0.10.26, 0.10.28, 0.10.29. Selected node.js version 0.10.29. Use package.json file to choose a different version. Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml Finished successfully. 

解决scheme是在门户中的Azure网站的configuration选项卡上将平台设置为64位。 然后我使用以下内容在我的节点项目的根目录下创build了一个IISnode.yml文件:

 loggingEnabled: true devErrorsEnabled: true 

现在,当我通过浏览器访问该网站时,我看到了详细的错误消息,显示cloudinary envvariables未configuration。 我将存储在我的项目.env文件中的内容添加到了我的azure网站门户页面configuration选项卡上的应用程序设置,并修复了一切!