Reputation: 425
I mean without hosting "index page" or "view", is that possible to host only node js code and database in azure or openshift. I'm server side developer, so I need to host it. Thanks in advance
Upvotes: 1
Views: 195
Reputation: 13918
Yes, the answer to your question is positive. You can start up with an empty nodejs application template provided by Azure.
Please login Azure portal=>click New button=>select "Web+Mobile"=>clcik See all=>type "Node JS Empty Web App" in the search bar=>select the template to create a new Azure Web App with a default nodejs application without any views.
After creating task, you can enable the Visual Studio online extension, and you can see and modify the scripts and modules in your application. You can refer to the answer of How to install composer on app service? for enabling the extension.
And login Azure portal, find your application in App Services, click Tools button on the header nav, click Visual Studio Online then click go, to login VSO editor.
After all, you can find your getting started application only contains one nodejs script, server.js
with:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('Hello, world!');
}).listen(process.env.PORT || 8080);
Upvotes: 1
Reputation: 114
Yes it is most-definitely possible to host on Azure. I have done it before. You might want to use Kudu to run your command line and run commands you are most comfortable with. You can install the nodejs template from the Web App gallery and then add "scm" to your link like so https://mynodesite.scm.azure-websites.net. It will give you a commad line like the one you have on your machine and have greater flexibility.
Yours to count on
Upvotes: 0
Reputation: 1716
Yes it is absolutely possible to host node.js APIs in Azure.
The easiest way to do this is to use Azure App Service, which will automatically detect a node app and configure itself to host correctly, assuming you adhere to some conventions (your main entrypoint should be a file called app.js in the root folder, etc.):
Here's a small node API sample I created for another SO question, it has no view component and can be deployed directly to Azure App Service as-is:
Node + Express.js API code sample
There are also a variety of hosted database options for Azure, here's merely a few possible options:
Any of these (and more) can be used from an Azure-hosted Node.js application.
Good luck!
Upvotes: 1
Reputation: 3812
it is possible to host NodeJS code (which, in your case, I suspect will be handling some routes like app.get('/path', function (req, res){...});
.
For further details and ideas, please look at the discussions here on hosting Node on Azure.
You can also look at the Azure support site for NodeJS. I hope this points you in the right direction to find useful resources.
Upvotes: 0