1.0.6 • Published 6 years ago

p-azure-storage v1.0.6

Weekly downloads
9
License
MIT
Repository
github
Last release
6 years ago

p-azure-storage

Adds a promise based API to the Azure Storage SDK

node npm Downloads Known Vulnerabilities

Important

Queue Service

These methods will block until a message is received, regardless of the timeout interval provided. The timeout will still be respected but if a message is not received in time, another request will be made. See below for rationale.

  • getMessagesAsync

Install

npm install p-azure-storage or yarn install p-azure-storage

Usage

Blob Service

import { createBlobService } from "p-azure-storage";

function handleResult(result) { ... }

function handleError(error) { ... }

// same arguments or environment variables
const service = createBlobService("my connection string");

// same arguments sans callback
// you do not get response information even if the SDK provided it
service.createBlockBlobFromLocalFileAsync("my-container", "my-blob", "path/to/my/file")
  .then(handleResult)
  .catch(handleError);

File Service

import { createFileService } from "p-azure-storage";

function handleResult(result) { ... }

function handleError(error) { ... }

// same arguments or environment variables
const service = createFileService("my connection string");

// same arguments sans callback
// you do not get response information even if the SDK provided it
service.doesShareExistAsync("my-share")
  .then(handleResult)
  .catch(handleError);

Queue Service

import { createQueueService } from "p-azure-storage";

function handleResult(result) { ... }

function handleError(error) { ... }

// same arguments or environment variables
const service = createQueueService("my connection string");

// same arguments sans callback
// you do not get response information even if the SDK provided it
service.getMessagesAsync("my-queue")
  .then(handleResult)
  .catch(handleError);

Table Service

import { createTableService } from "p-azure-storage";

function handleResult(result) { ... }

function handleError(error) { ... }

// same arguments or environment variables
const service = createTableService("my connection string");

// same arguments sans callback
// you do not get response information even if the SDK provided it
service.createTableIfNotExistsAsync("my-table")
  .then(handleResult)
  .catch(handleError);

Cancelling blocking requests

import azure from "p-azure-storage";

function handleResult(result) { ... }

function handleError(error) { ... }

function handleComplete() { ... }

const service = azure.createService();
const promise = service.blockingMethodAsync()
  .then(handleResult) // is NOT called
  .catch(handleError); // is NOT called
  .finally(handleComplete); // is called
...
promise.cancel();

Why block?

In the majority of cases I have come across, if a consumer does not receive a message before a timeout, the consumer is immediately going to create another request. I don't think that it should be left up to individual projects to implement this on their own.

Azure Documentation

Storage

Issues

This library was generated, report issues here.

License

This source code is licensed under the MIT license found in the LICENSE.txt file.

The Azure SDK has its own license

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago