Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

This branch is 2 commits ahead, 2992 commits behind Azure:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Windows Azure SDK for Node.js

This project provides a set of Node.js packages that make it easy to access the Windows Azure storage and queue services. For documentation on how to host Node.js applications on Windows Azure, please see the Windows Azure Node.js Developer Center.


  • Tables
    • create and delete tables
    • create, query, insert, update, merge, and delete entities
  • Blobs
    • create, list, and delete containers, work with container metadata and permissions, list blobs in container
    • create block and page blobs (from a stream, a file, or a string), work with blob blocks and pages, delete blobs
    • work with blob properties, metadata, leases, snapshot a blob
  • Queues
    • create, list, and delete queues, and work with queue metadata
    • create, get, peek, update, delete messages

Getting Started

Download Source Code

To get the source code of the SDK via git just type:

git clone
cd ./azure-sdk-for-node

Download Package

Alternatively, to get the source code via the Node Package Manager (npm), type

npm install azure

You can use these packages against the cloud Windows Azure Services, or against the local Storage Emulator.

  1. To use the cloud services, you need to first create an account with Windows Azure. You need to set the AZURE_STORAGE_ACCOUNT and the AZURE_STORAGE_ACCESS_KEY environment variables to the storage account name and primary access key you obtain from the Azure Portal.
  2. To use the Storage Emulator, make sure the latest version of the Windows Azure SDK is installed on the machine, and set the EMULATED environment variable to any value ("true", "1", etc.)


Table Storage

To ensure a table exists, call createTableIfNotExists:

var tableService = azure.createTableService();
tableService.createTableIfNotExists('tasktable', function(error){
        // Table exists

A new entity can be added by calling insertEntity:

var tableService = azure.createTableService(),
    task1 = {
        PartitionKey : 'tasksSeattle',
        RowKey: '1',
        Description: 'Take out the trash',
        DueDate: new Date(2011, 12, 14, 12) 
tableService.insertEntity('tasktable', task1, function(error){ 
        // Entity inserted

The method queryEntity can then be used to fetch the entity that was just inserted:

var tableService = azure.createTableService();
tableService.queryEntity('tasktable', 'tasksSeattle', '1', function(error, serverEntity){
        // Entity available in serverEntity variable

Blob Storage

The createContainerIfNotExists method can be used to create a container in which to store a blob:

var blobService = azure.createBlobService();
blobService.createContainerIfNotExists('taskcontainer', {publicAccessLevel : 'blob'}, function(error){
        // Container exists and is public

To upload a file (assuming it is called task1-upload.txt, it contains the exact text "hello world" (no quotation marks), and it is placed in the same folder as the script below), the method createBlockBlobFromStream can be used:

var blobService = azure.createBlobService();
blobService.createBlockBlobFromStream('taskcontainer', 'task1', fs.createReadStream('task1-upload.txt'), 11, function(error){
        // Blob uploaded

To download the blob and write it to the file system, the getBlobToStream method can be used:

var blobService = azure.createBlobService();
blobService.getBlobToStream('taskcontainer', 'task1', fs.createWriteStream('task1-download.txt'), function(error, serverBlob){
        // Blob available in serverBlob.blob variable


The createQueueIfNotExists method can be used to ensure a queue exists:

var queueService = azure.createQueueService();
queueService.createQueueIfNotExists('taskqueue', function(error){
        // Queue exists

The createMessage method can then be called to insert the message into the queue:

var queueService = azure.createQueueService();
queueService.createMessage('taskqueue', "Hello world!", function(error){
        // Message inserted

It is then possible to call the getMessage method, process the message and then call deleteMessage inside the callback. This two-step process ensures messages don't get lost when they are removed from the queue.

var queueService = azure.createQueueService(),
    queueName = 'taskqueue';
queueService.getMessages(queueName, function(error, serverMessages){
        // Process the message in less than 30 seconds, the message
        // text is available in serverMessages[0].messagetext 

        queueService.deleteMessage(queueName, serverMessages[0].messageid, serverMessages[0].popreceipt, function(error){
                // Message deleted

For more examples please see the Windows Azure Node.js Developer Center.

Need Help?

Be sure to check out the Windows Azure Developer Forums on Stack Overflow if you have trouble with the provided code.


For feedback related specifically to this SDK, please use the Issues section of the repository.

For general suggestions about Windows Azure please use our UserVoice forum.

Learn More

Windows Azure Node.js Developer Center

Something went wrong with that request. Please try again.