Node.js applications uses packages to add functionality
You can think of these as libraries
The goal of this post is to show you how to upload these packages up to Azure Mobile Services so that you can give your node code more power
This post is about adding QueryString to Azure Mobile Services.
You will need a GIT client.
Git is a distributed revision control and source code management (SCM) system with an emphasis on speed.
Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005.
We will need Git in order to be able to add node packages to Azure mobile services
Figure 1: Downloading the Windows Git Client
You can download it here: http://git-scm.com/download/win
Once you install, consider a reboot.
Your first goal is to download the Node.js code and packages down to your local machine
You will then modify the package package.json, which contains a list of packages that need to be installed into Azure Mobile Services.
You can't just copy packages directly. You must use Git to copy packages Azure mobile services
Azure Mobile Services directly supports git.
Navigate to the Azure Portal
Select Mobile Services
Select the CONFIGURE menu
Figure 2: Getting to the Git URL from Azure Mobile Services
Once you copy the url to the clipboard, proceed to the next step.
You will need to open a command prompt
Type in git clone [ your git url from the
Figure 3: Cloning the repository to your local computer
You will need to provide a user name and password
Figure 4: What your screen should look like
Now if you take a look at the c:\IoT folder (the one I am using), you will see the following:
Figure 5: Viewing the folder structure of the cloned repository
Now navigate to the raspberrypiservice folder. Yours will be different. You defined it when you created your Azure Mobile Service.
Navigate into the service folder and view the files
Figure 6: Moving to the service folder (to see package.json)
You can see the package.json file.
This is the key file to edit.
Now you will need to modify the package.json file to include new node packages.
For example purposes, we will include the packages qs (QueryString)
We need to modify the dependencies section of package.json.
We will add qs there
Figure 7: Viewing the package.json file
Notice the qs is now part of dependencies
Figure 8: Adding qs (querystring) as a dependency
You will need to commit the changes before you push them up to the portal.
The command is, git commit .
Figure 9: Commiting the changes
You will be asked to enter in a commit comment. Seen in yellow below.
Figure 10: Adding a comment for the changes
In the editor VI, you w ill hit w follow ed by q .
Now we will push our changes upstream.
The command for this is simple: git push [remote-name] [branch-name].
But we want to push our master branch to the origin server (Azure Mobile Services)
We will push our work back up to Azure Mobile Services with this command:
Figure 11: Pushing the changes back up to Azure Mobile Services
We completed what we set out to do
We have added the node package qs to our Azure Mobile Services
We will now make use of the **qs ** package in node.js
Figure 12: Adjusting the node.js code to use qs (Query String Package)
As you can see in the figure above, we are now able to leverage the node package known as qs .