Deploying nodejs in our own server - node.js

I am new to nodejs. I've created a simple webservice and it works on local but by using node app/nodemon app. Well I want to publish it internet and deploy my service in our server. (We do not want to use external servers/services such as heroku, azure etc.)
As I searched, peopel mostly deployed those services. So what is the best way to deploy a WS with nodejs in your own server?
I have a windows server for now but would like to use may be in linux platform later.

Related

Is it possible to deploy NodeJS app without SSH access?

According to that answer hosting that allows deploy NodeJS apps
will generally give you (at a minimum) shell access (via SSH) which
you can use to run the Node.JS application
But is it possible to deploy NodeJS application without access to ssh? On my hosting plan, I have only FTP access and I was wandering if I can do that or should I change hosting provider?
If your app is fully static you can build it into static js files (i.e. npm run build in vue.js) and then it should work on ftp hosting. Note, however, that in this case if your usage is low you can use something like Google App Engine or Netlify and essentially get free hosting for your static app.
However, if your app involves some back-end operations, i.e. express.js then you need to be able to run node.js server itself and you need a VPS-based or container-based hosting.
Feel free to reach out to me via discord here and ask more questions - https://discord.gg/UTxjBf9juQ.

how to run a node server in an azure virtual machine permanently?

I build a web based mobile app (using react), which I'm hosting as an Azure Web app. This website is connected to a node server, which I'm hosting using a azure virtual machine (I don't know if this is the best approach, maybe I should host this as a webapp instead of VM ?).
I'm still new to this strategie of developing a web based mobile app and connecting it to a hosted backend in the cloud so I apologize if this is a trivial question.
I'm using websockets to connect my frontend to the node server and then I consume messages. I don't have a database it is a simple application.
The steps I'm doing to run the app are:
I connect to the Azure VM from my laptop with ssh
run my server using node server.js
When the server is runing, I can refresh my website and everything works fine
Now, the problem is that I want the node server to run all the time. However, I noticed that the server stops running when I deconnect (ssh) my laptop from the virtual machine. So I find myself doing these steps (connecting to the VM with ssh and running the server manually) each time I want to use the app.
Is there a way to do this so that the node server runs all the time without stoping? Also since I'm new to this, is this the right way to deploy frontend and backend? I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
(Since part of your question is around "Is there a better way?", I would answer that instead of fixing the issue in your current VM hosting :)).
To take full advantage of cloud for your applications, PaaS is always preferred over IaaS. In this case, unless you have any specific reason, you should deploy your backend Node app in another App Service (aka Web App). Or you can consider Azure Function also if your node app has a small set of APIs, but it will require code update. Both support multiple platforms including node.js. Since you mentioned you are leveraging Web App for your react mobile app, so I hope you are already bit familiar with it. Also since Azure Function would require code change, so Web App is preferred this case.
Note: I omitted other solutions like AKS, Service Fabric etc. for now, since currently we are talking about the problem of deploying only a single app, for which those will be overkill at this moment.
Also, to your point
I assume I can't deploy both frontend and backend in the same Azure webapp or am I wrong?
Yes technically you can, depending on your scenario by "bundling" into a single app if both are in same platform (like Node in this case). Though whether one should do that would be an opinionated answer. But even if you keep those separate, you can still leverage single App Service Plan for cost saving. So keeping separate like you have now is what I would suggest to maintain "separation of concern".

Azure : Deploy Angular(Front-End) & Node (Back-End) app without VM

I am new to Azure. I have never used azure. So don't mind if this is some silly question.
I have a client who also doesn't know much about deploying.
I have angular/node apps. He wants to host on Azure WITHOUT using a VM.
I am not sure about azure. So i don't know how to deploy without VM.
I know to deploy with RDP(Remote Desktop).
Can anyone help me with this. Is there a way to deploy angular & node app without VM?
Is there any specific documentation for it? Which services will i need in Azure?
Thanks in advance!
Except Azure VM, there are normally two ways to deploy Node.js app on Azure which include App Service - Web Apps and Web Apps for Containers, please see the links below to know these guides.
For deploying Node.js app on Azure Web Apps.
Create a Node.js web app in Azure
Tutorial: Build a Node.js and MongoDB web app in Azure
To deploy the app with a ZIP file, or via FTP, cloud sync, or deploy continuously, or from local Git, etc. You can see more at the left sidebar of these pages.
For deploying Node.js app on Azure Web App for Containers, it's a simple way to deploy the app on Azure as similiar as on local docker.
Create a Node.js web app in Azure App Service on Linux
Build a Node.js and MongoDB web app in Azure App Service on Linux
To deploy via FTP, cloud sync, or deploy continuously, or from local git, etc. Also, you can see more at the left sidebar of these pages.
Some important tools will help deploying easier.
Deploy via VSCode, you can refer to these offical documents for WebApp(App Services) or Container(Docker Images).
To deploy on WebApp not Container, Kudu is a common tool for debuging and deployment. Meanwhile, for Node.js app, we need to use iisnode to connect IIS as revese proxy for your app, and configure the web.config file via follow the kudu wiki document. The Kudu wiki is very useful and valuable for new to Azure.
There are more details for this topic which can not be listed one by one at here, but the above these are necessary. The offical guide for Javascript developers is helpful for new to Azure.
Jay Gong posted a great answer for hosting on Azure. However, you might want to ask your client if s/he means s/he wants a micro services architecture. For more information on micro services, check out this link.
The other viable option would be an App Service (which is an Azure service that manages deployment and abstracts a lot away, but there's a VM under the hood)? Without a VM for hosting, it would be rather difficult to do anything in the cloud on Azure - the only other option is local hosting, which would be without Azure. I would argue that it ruins the purpose of using cloud services, as it seems your client is confused.

deploying frontend and backend to the same web service on azure

i have a web app that has a seperate nodejs backend and angular frontend.
is it possible to make them both run on the same azure web service? or do i need a stand alone service for each?
my nodejs server is just a light API that feeds my angular app with some statistical data to render it. if it is possible what would be the way to do it?
since i am using typescript i know i need to push my nodejs using zipdeployment and i know i need to use visual studio to push my angular project to azure. but when i want to run both on the same service, how do i do it?
is it possible to make them both run on the same azure web service? or do i need a stand alone service for each?
If you choose the Web App on Windows OS, IIS allows you to configure multiple virtual applications within a single website. For this approach, you could follow Deploying multiple virtual directories to a single Azure Website. Note: The multiple virtual applications would share the same application pool.
As kim mentioned, you pay for the App Service Plan, not for the Web App. You could also host nodejs backend and angular frontend in different web apps under the same app service plan.
For the deployment, you could leverage VS publish wizard or manually upload your files via KUDU or FTP. Moreover, you could also follow Deploy the app section about various approaches for deployment.
You can run multiple web sites in different web apps in Azure so that they are sharing the same Azure App Service.
You can think of the App Service as a virtual machine offering resources for your applications. How many web apps you can run simultaneously depends on the size of your plan, see this page for details.
This way you can deploy them separately, manually or automatically using e.g. VSTS.

How do I update the version of iisnode on a Windows Azure Cloud Service image

I had a working Windows Azure Web Site running my node.js app and everything was working fine. I ended up needing to run a native node.js module (fibers), which necessitated that I move to a Windows Azure Cloud Service. I used the Convert to Azure Cloud Service wizard, which created a web role that allowed me to deploy my app as a cloud service and run fibers under node. So far so good.
My app requires WebSockets, which are supported under Azure Web Sites (more or less automagically when you turn it on from the config UX). I've been fighting to get WebSockets working with the Cloud Service for a few days now, and I have determined that my problem is that the version of iisnode that runs by default in a Cloud Service is too old to support node.js WebSockets in the normal way. The Cloud Service installs iisnode version 1.21 and the WebSockets support in iisnode didn't show up until version 2.0 (I have no idea why the Cloud Service image uses that crusty old version of iisnode).
Note that I don't want to use a worker role and listen on a different port (which I gather is how a lot of people address this).
Unfortunately, I cannot figure out how to install a more up to date version of iisnode in my Cloud Service (I gather that it's possible to run an installer at the startup of the Cloud Service (possibly via setup_web.cmd), but that's as far as I've gotten.
Any pointers on what I need to do to get my Azure Cloud Service running a newer version of iisnode?
To update the version of iisnode installed on Azure Hosted Service you need to:
Download the newest x64 installer for iisnode from http://go.microsoft.com/?linkid=9784331
Include that *.msi file in the package you are deploying to the Hosted Service.
In your setup_web.cmd, install the new iisnode with msiexec /i iisnode-full-iis7-v0.2.7-x64.msi /passive. This must be run as admin, but then I believe setup_web.cmd already runs as admin.
Alternativelty, for a one-off installation, you can just TS to the machine and install it manually.
By the way, what is preventing you from using the native module in Windows Azure Web Sites?

Resources