如何让我的Azure网站运行“node server.js”

时间:2022-04-26 14:43:33

I'm new to Azure and NodeJS so I apologise in advance if this question is confusing. I'm still trying to understand the basics. Right now, I have a node.JS website that I'm just trying to deploy onto Azure as a webiste.

我是Azure和NodeJS的新手,所以如果这个问题令人困惑,我会提前道歉。我还在努力了解基础知识。现在,我有一个node.JS网站,我只想尝试作为网站部署到Azure。

I have the website deployed using WebMatrix, however, I have a expressJS server side where requires me to actually execute the code "node server.js". On my local machine, I just execute this in command prompt and my server boots up.

我使用WebMatrix部署了网站,但是,我有一个expressJS服务器端,需要我实际执行代码“node server.js”。在我的本地计算机上,我只是在命令提示符下执行此操作,然后我的服务器启动。

However, I'm not sure where I'm supposed to run this on azure?

但是,我不确定我应该在天蓝色的地方运行它?

Is it possible to do this using Azure's website service or do I need to create another azure service type like maybe a cloud service or VM?

是否可以使用Azure的网站服务执行此操作,还是需要创建另一种天蓝色服务类型,例如云服务或VM?

1 个解决方案

#1


1  

You can either use a VM or you can use a web service for node.js. The first is cheaper. So if you go with this option you have to create a new virtual machine. Let's say a Ubuntu LTS. follow this tutorial for how to upload a vm. Now, you have to login in the VM using a ssh program as putty. Copy your code to a folder or use a program for secure copy as winSCP to do that. In order to deploy node.js at ubuntu follow this commands:

您可以使用VM,也可以使用node.js的Web服务。第一个更便宜。因此,如果使用此选项,则必须创建新的虚拟机。让我们说一个Ubuntu LTS。按照本教程了解如何上传虚拟机。现在,您必须使用ssh程序作为putty登录VM。将您的代码复制到一个文件夹或使用程序进行安全复制,作为winSCP来执行此操作。要在ubuntu上部署node.js,请遵循以下命令:

sudo apt-get install python-software-properties python g++ make

sudo add-apt-repository ppa:chris-lea/node.js

sudo apt-get install nodejs

sudo apt-get install npm -y

and then you are able to execute

然后你就可以执行了

node server.js

Remember to open the port that node.js working to make visable to outside world.

请记住打开node.js工作以使外部世界可见的端口。

if you insist to use an azure service you find useful this link.

如果你坚持使用azure服务,你会发现这个链接很有用。

#1


1  

You can either use a VM or you can use a web service for node.js. The first is cheaper. So if you go with this option you have to create a new virtual machine. Let's say a Ubuntu LTS. follow this tutorial for how to upload a vm. Now, you have to login in the VM using a ssh program as putty. Copy your code to a folder or use a program for secure copy as winSCP to do that. In order to deploy node.js at ubuntu follow this commands:

您可以使用VM,也可以使用node.js的Web服务。第一个更便宜。因此,如果使用此选项,则必须创建新的虚拟机。让我们说一个Ubuntu LTS。按照本教程了解如何上传虚拟机。现在,您必须使用ssh程序作为putty登录VM。将您的代码复制到一个文件夹或使用程序进行安全复制,作为winSCP来执行此操作。要在ubuntu上部署node.js,请遵循以下命令:

sudo apt-get install python-software-properties python g++ make

sudo add-apt-repository ppa:chris-lea/node.js

sudo apt-get install nodejs

sudo apt-get install npm -y

and then you are able to execute

然后你就可以执行了

node server.js

Remember to open the port that node.js working to make visable to outside world.

请记住打开node.js工作以使外部世界可见的端口。

if you insist to use an azure service you find useful this link.

如果你坚持使用azure服务,你会发现这个链接很有用。