NodeJS VM by Anarion Technologies
Node.js is an open-source, cross-platform JavaScript runtime environment that revolutionizes server-side scripting by enabling JavaScript to be used for backend development. It is built on Chrome’s V8 JavaScript engine, known for its high performance and efficient execution of JavaScript code. Node.js uses an event-driven, non-blocking I/O model, which makes it lightweight and highly efficient, particularly suitable for data-intensive real-time applications that run across distributed devices.
One of the key advantages of Node.js is its ability to handle many concurrent connections with high throughput, making it ideal for building scalable network applications. This is achieved through its single-threaded event loop, which allows it to manage multiple connections without the need to create new threads for each request. As a result, Node.js applications can efficiently handle thousands of simultaneous connections.
Node.js also has a robust and ever-growing ecosystem, powered by npm (Node Package Manager), which hosts thousands of open-source libraries and modules that developers can use to add functionality to their applications. This extensive ecosystem significantly speeds up development time by providing reusable components for a wide range of tasks, from handling web frameworks and database interaction to implementing security features and utility functions.
Furthermore, Node.js is widely adopted in various domains, including web development, API services, microservices architectures, and even Internet of Things (IoT) solutions. Popular frameworks such as Express.js, Koa.js, and Nest.js are built on top of Node.js, providing developers with tools to create robust and maintainable web applications.
To subscribe to this product from Azure Marketplace and initiate an instance using the Azure compute service, follow these steps:
1. Navigate to Azure Marketplace and subscribe to the desired product.
2. Search for “virtual machines” and select “Virtual machines” under Services.
3. Click on “Add” in the Virtual machines page, which will lead you to the Create a virtual machine page.
4. In the Basics tab:
- Ensure the correct subscription is chosen under Project details.
- Opt for creating a new resource group by selecting “Create new resource group” and name it as “myResourceGroup.”
5. Under Instance details:
- Enter “myVM” as the Virtual machine name.
- Choose “East US” as the Region.
- Select “Ubuntu 18.04 LTS” as the Image.
- Leave other settings as default.
6. For Administrator account:
- Pick “SSH public key.”
- Provide your user name and paste your public key, ensuring no leading or trailing white spaces.
7. Under Inbound port rules > Public inbound ports:
- Choose “Allow selected ports.”
- Select “SSH (22)” and “HTTP (80)” from the drop-down.
8. Keep the remaining settings at their defaults and click on “Review + create” at the bottom of the page.
9. The “Create a virtual machine” page will display the details of the VM you’re about to create. Once ready, click on “Create.”
10. The deployment process will take a few minutes. Once it’s finished, proceed to the next section.
To connect to the virtual machine:
1. Access the overview page of your VM and click on “Connect.”
2. On the “Connect to virtual machine” page:
- Keep the default options for connecting via IP address over port 22.
- A connection command for logging in will be displayed. Click the button to copy the command. Here’s an example of what the SSH connection command looks like:
“`
ssh [email protected]
“`
3. Using the same bash shell that you used to generate your SSH key pair, you can either reopen the Cloud Shell by selecting >_ again
or going to https://shell.azure.com/bash.
4. Paste the SSH connection command into the shell to initiate an SSH session.
Usage/Deployment Instructions
Anarion Technologies – NodeJS
Note: Search product on Azure marketplace and click on “Get it now”
Click on Continue
Click on Create
Creating a virtual machine, enter or select appropriate values for zone, machine type, resource group and so on as per your choice.
How to Set Up the Node.js Environment
After installing Node and NPM, you need to set up the Node environment by creating a new Node project.
Use the command below to create a new directory/folder where you want to test a simple “Hello World” type Node project.
How to Set Up the Node.js Environment
After installing Node and NPM, you need to set up the Node environment by creating a new Node project.
Use the command below to create a new directory/folder where you want to test a simple “Hello World” type Node project.
$ mkdir my-node-project
Creating a new directory/folder to test a simple “Hello World” program on Node
Navigate to the my-node-project directory by using the command below:
$ cd my-node-project
Changing the directory to enter into that newly created directory/folder
Initialize the new Node project like this:
$ npm init -y
This command will create a “package.json” file containing your project’s metadata and dependencies. Here is the JSON output:
Now run the setup with the simple command. For this, I am going to create a new file called app.js using the nano text editor in the terminal.
$ sudo nano app.js
Once the text editor opens, type the below code:
# console.log(“Hello, Node.js from Ubuntu!”);
Writing a simple console.log code in the app.js file using nano
Use Ctrl+ X & Shift+Y Press Enter to save the file
Save the app.js file with the newly added line of code
Now, it is time to check the output and see whether it’s working or not.
Use the command below:
$ node app.jsRunning the app.js file using Node
It is working!
Cheers!