npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

azure-storage-legacy

v0.11.2

Published

Microsoft Azure Storage Client Library for node for back compat with older versions of node sdk

Downloads

41,787

Readme

Microsoft Azure SDK for Node.js - Legacy Storage

This project provides a Node.js package that lets you consume Azure storage services. This package exists to provide back compatibility with previous versions of the azure sdk for node.

  • API version: 2013-03-01

Features

  • Blob client
  • Table Store client
  • Queue client

How to Install

npm install azure-storage-legacy

How to Use

Usage

Table Storage

To ensure a table exists, call createTableIfNotExists:

var tableService = storage.createTableService();
tableService.createTableIfNotExists('tasktable', function(error){
    if(!error){
        // Table exists
    }
});

A new entity can be added by calling insertEntity:

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

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

var tableService = storage.createTableService();
tableService.queryEntity('tasktable', 'tasksSeattle', '1', function(error, serverEntity){
    if(!error){
        // 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 = storage.createBlobService();
blobService.createContainerIfNotExists('taskcontainer', {publicAccessLevel : 'blob'}, function(error){
    if(!error){
        // Container exists and is public
    }
});

To upload a file (assuming it is called task1-upload.txt and it is placed in the same folder as the script below), the method createBlob can be used. This method will return a writable stream which can be writen to, for instance, through piping:

var blobService = storage.createBlobService();

fs.createReadStream('task1-upload.txt').pipe(blobService.createBlob('taskcontainer', 'task1', storage.Constants.BlobConstants.BlobTypes.BLOCK));

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

var blobService = storage.createBlobService();

blobService.getBlob('taskcontainer', 'task1').pipe(fs.createWriteStream('task1-download.txt'));

To create a SAS URL you can use the getBlobUrl method. Additionally you can use the date helper functions to easily create a SAS that expires at some point relative to the current time.

var blobService = storage.createBlobService();

//create a SAS that expires in an hour
var sharedAccessPolicy = {
    AccessPolicy: {
        Expiry: storage.date.minutesFromNow(60);
    }
};

var sasUrl = blobService.getBlobUrl(containerName, blobName, sharedAccessPolicy);

Storage Queues

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

var queueService = storage.createQueueService();
queueService.createQueueIfNotExists('taskqueue', function(error){
    if(!error){
        // Queue exists
    }
});

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

var queueService = storage.createQueueService();
queueService.createMessage('taskqueue', 'Hello world!', function(error){
    if(!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 = storage.createQueueService(),
    queueName = 'taskqueue';
queueService.getMessages(queueName, function(error, serverMessages){
    if(!error){
        // 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){
            if(!error){
                // Message deleted
            }
        });
    }
});

Related projects

Impressions