Is Node js used in cloud computing

Build and deploy a Node.js web application with Express in Azure Cloud Services (classic)

Important

Azure Cloud Services (Extended Support) is a new Azure Resource Manager-based deployment model for Azure Cloud Services. As part of this change, Azure Cloud Services instances that run under the Azure Service Manager-based deployment model have been renamed "Cloud Services (classic)". Azure Cloud Services (Extended Support) should be used for all new deployments.

The core runtime of Node.js comprises a number of elementary functions. When developing a Node.js application, developers often use third-party modules that have additional functionality. In this tutorial, you will create a new application using the Express module, which provides an MVC framework for creating Node.js web applications.

Below is a screenshot of the finished application:

Create a cloud service project

Note

To successfully complete the steps in this section, you must have a working installation of Node.js and the Azure SDK for Node.js for your platform.

Follow the steps below to create a new cloud service project named 'expressapp':

  1. Look in the Start menu or on the Home screen to Windows PowerShell. Then right click Windows PowerShell, and choose Execute as administrator out.

  2. Change the directory to c: \ node, and enter the following commands to create a new solution named expressapp and a web roll with the name WebRole1 to create:

    Note

    Used by default Add-AzureNodeWebRole an older version of Node.js. The statement above Set-AzureServiceProjectRole tells Azure to use Node 0.10.21. Note that parameters are case-sensitive. You can verify that the correct version of Node.js has been selected by editing the enginesProperty in WebRole1 \ package.json check.

Install Express

  1. Install the express generator with the following command:

    The output from the npm command should look something like this.

  2. Change the directory to WebRole1 , and create a new application with the express command:

    You will be asked to overwrite the previously created application. Give y or yes one to continue. Express creates the app.js file and a folder structure for creating the application.

  3. Enter the following command to install additional dependencies defined in the package.json file.

  4. Copy the file with the following command bin / www to server.js. This enables the cloud service to find the entry point for this application.

    After executing this command, the file server.js in the "WebRole1" directory.

  5. Remove in server.js one of the '.' characters from the following line.

    After this change, the line should look like this.

    This change is necessary because the file (formerly bin / www,) was moved to the same directory as the required app file. Save the file server.js subsequently.

  6. Use the following command to run the application in the Azure emulator:

Change the view

Now change the view to show the message 'Welcome to Express in Azure'.

  1. Enter the following command to open the index.jade file:

    Jade is the standard display engine used by express applications. For more information on the Jade display engine, visit http://jade-lang.com.

  2. Change the last line of text by typing in Azure append.

  3. Save the file and exit the editor.

  4. When you refresh the browser, the changes will be reflected.

After testing the application with the cmdlet, stop the emulator Stop-AzureEmulator .

Publish the application to Azure

Use the cmdlet in the Azure PowerShell window Publish-AzureServiceProject to make the application available in a cloud service.

As soon as the deployment is complete, the browser opens and the website is displayed.

Next Steps

Visit the Node.js Developer Center for more information.