Performance Zone is brought to you in partnership with:

Leigh has been in the technology industry for over 15 years, writing marketing and technical documentation for Sun Microsystems, Wells Fargo, and more. She currently works at New Relic as a Marketing Manager. Leigh is a DZone MVB and is not an employee of DZone and has posted 106 posts at DZone. You can read more from them at their website. View Full User Profile

Node.js Love w/ PaaS: Part 1 - Deploying on Azure

11.06.2012
| 3591 views |
  • submit to reddit

 Originally authored by Adron Hall

The Platform-as-a-Service (PaaS) world is making the deployment of applications extremely easy. And the days of complex deploys are starting to wither away. (At least, I hope they are for you, you’re moving to a PaaS-enabled environment or deploying one yourself, right?) As promised in my last entry, here’s code and the related bits to deploy on several of the major PaaS providers! Before diving into them, I kicked together something that’ll look pretty cool once deployed. Something that isn’t merely a ‘Hello World’ application.

Code Cred with Coderwall
For this Node.js web app I’ve used these bits of tech.

* Node.js
* express.js
* Jade
* Coder Wall snippets

I’ve created an example app here:

Building a Node.js + Express.js + Jade Code Portfolio and continued.

And you can also clone or fork my code here on github:

https://github.com/Adron/adronbhall

Before moving forward, check the app to make sure it runs OK. If you want to learn a little bit more about what I did to put this application together read my posts, Building Node.js + Express.js + Jade + Coderwall… Part 1 and Part 2, on my blog Composite Code . For an example, all of the steps required to deploy Node.js apps on a clean Ubuntu install are documented on Building a Node.js Application on a Linux Instance…. This second entry really shows you how simple a PaaS deployment is compared to trying to setup and maintain an instance of a server manually.

The basic setup of the application includes a main page that pulls content via AJAX and respective JSON results onto the page. You can see the JavaScript and code from the main page below. There are a few other things in there, but it gives you an idea of the proudify plugin, the over over, etc. The proudify code plugin is available here. Props to Icebreaker (Mihail Szabolcs of Romania) for knocking that code out and getting it on github.

$('#coderwall').proudify({username:'adron',service:'coderwall'});
$('.proudify.social').hover(
function(){
$(this).animate({"left": "+=74px"}, "fast");
},
function(){
$(this).animate({"left": "-=74px"}, "fast");
});
$("#navBeta").accordion({ header: "h3" });

With that, let’s talk PaaS deployment options and walk the walk. It’s deployment happiness time!

Deployment Happiness
For now, I’ll be kicking this off with a few deployments from a couple of providers. In my next article, I’ll cover additional key PaaS providers, review what each of them do well and point out where the rough parts are. For each of these deployments, I’m going to be deploying the code above from the perspective of having an account setup, but not having installed any SDK, CLI or other tooling. So the overall steps for each deployment will include:

1. Installation of needed software to do a deployment to X target.
2. Changes or configurations that are needed to the project itself.
3. Deployment of the project.

Deployment #1: Windows Azure
Windows Azure recently went through massive changes and a major face lift. With this update, it has really stepped up to become a major contender in the PaaS space when deploying a Node.js application.

To get started, login to the dashboard with your account.

Azure screenshot 1

Then install the SDK for your particular platform, by navigating over to the Windows Azure Node.js site and picking up the appropriate SDK (in my case the OS-X SDK,) downloading the file and beginning the installation.

Node.js Development Center

Azure Installer

Install Windows Azure SDK

Now that the SDK is installed, there are multiple tools available for deployment. Choose your favorite, and return to or open the management portal. Once in the portal, click the Web Sites tab (left arrow) and then Create a Web Site link on the main content area (right arrow).

Windows Azure screenshot 2

Afterwards, the Windows Azure portal pops up (very elegantly might I add,) and displays the options for creating the application.

Windows Azure screenshot 3

Use the Quick Create option and select the default region where you want to create the application. Once completed. click the Create button. The application will be created in the portal and displayed as shown below.

Windows Azure screenshot 4

Click the application and select Setup Git Publishing.

Windows Azure screenshot 5

From there Git publishing integrates with your application. It takes a few seconds with a nicely displayed spinning dial. (I’m not really sure what is happening here, but whatever it takes to integrate with Git is cool by me.)

Windows Azure screenshot 6

When the Git screen displays, you know everything went according to plan.

Windows Azure screenshot 7

If you click the Browse button, you’ll see a nice screen telling you the website has not been deployed yet. To deploy the website now, navigate in your bash, msysgit, powershell or whatever command line tool you use to the directory of the project. Once in the project, add a git repository remote connection per the instructions displayed on the Git page. Click on the Git link to display this page.

Windows Azure screenshot 8

Here are the specific commands taken to add a remote and deploy the site.

$ git remote add azure https://yourusername@coderwallz.scm.azurewebsites.net/coderwallz.git

After you’ve added the remote point check, see if everything is correct by viewing the remote end points.

$ git remote -v

The results should display as shown below.

Screenshot 9

After the remote point is added, do a push to the git repository. This is when the famous git deploy magic happens.

$ git push azure master

Screenshot 10

Clicking the dropdown menu displays the multiple stages of deployment as they occur from the git push.

Windows Azure screenshot 11

Once the deployment is done, refresh the portal page and you’ll find that the Git deploy Node.js Application is running.

Windows Azure screenshot 7

Clicking Browse opens another window to view the just deployed application.

Summary

This is the first of what will be a number of Node.js Application deployment tutorials for a number of PaaS providers. So stay tuned, and I’ll deploy to each one and wrap-up with a thorough description of their differences.

Cheers!


Published at DZone with permission of Leigh Shevchik, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)