I am trying to deploy a plain keystone.js starter application built in node.js, to Azure Website's Shared Tier.
I am getting an error after the deployment
The page cannot be displayed because an internal server error has occurred.
I thought it might be because the main server file was called keystone.js so I renamed it to index.js. This didnt fix it.
Next, I thought it could be an issue because keystone defaults to port 3000 so I added in port information in my index.js file. Here it is:
// 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();
Still no luck. However, this works great on my local machine, just not in Azure. Any ideas?
UPDATE: I updated my main server file to be named "server.js". I did some digging and looked at the deployment log in Azure and found this:
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.
The solution was to set the platform to 64bit on the configuration tab of your Azure website in the portal. I then created a IISnode.yml file at the root of my node project with the following content:
loggingEnabled: true
devErrorsEnabled: true
Now when I accessed the site via the browser I saw detailed error messages, which showed that the cloudinary env variable wasn't configured. I added the content that was stored in my projects .env file to the app settings on the configuration tab of my azure website portal page and that fixed everything!