1.0.6 • Published 6 years ago
p-azure-storage v1.0.6
p-azure-storage
Adds a promise based API to the Azure Storage SDK
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
Issues
This library was generated, report issues here.
License
This source code is licensed under the MIT license found in the LICENSE.txt file.