# azure-storage-legacy

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

Latest version **0.11.2** (published 2020-07-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install azure-storage-legacy
pnpm add azure-storage-legacy
yarn add azure-storage-legacy
bun add azure-storage-legacy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.2 |
| Published | 2020-07-27 |
| First published | 2014-06-05 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 476 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1174 |
| Author | Microsoft Corporation |
| Maintainers | windowsazure |
| Keywords | node, azure |

## Links

- npm: https://www.npmjs.com/package/azure-storage-legacy
- Repository: https://github.com/Azure/azure-sdk-for-node
- Homepage: http://github.com/Azure/azure-sdk-for-node
- Issues: http://github.com/Azure/azure-sdk-for-node/issues
- npm.io page: https://npm.io/package/azure-storage-legacy

## Dependencies (3)

- [mime](https://npm.io/package/mime.md) ^1.6.0
- [underscore](https://npm.io/package/underscore.md) ^1.8.3
- [azure-common](https://npm.io/package/azure-common.md) ^0.9.13

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.11.2 (latest) — 2020-07-27
- 0.11.1 — 2019-07-11
- 0.10.3 — 2018-06-12
- 0.10.2 — 2016-09-02
- 0.10.1 — 2015-06-08
- 0.10.0 — 2015-05-04
- 0.9.14 — 2015-03-25
- 0.9.13 — 2015-01-21
- 0.9.11 — 2014-09-10
- 0.9.10 — 2014-08-12
- 0.9.9 — 2014-07-30
- 0.9.8 — 2014-06-23
- 0.9.7 — 2014-06-05

## 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

```bash
npm install azure-storage-legacy
```

## How to Use

## Usage

### Table Storage

To ensure a table exists, call **createTableIfNotExists**:

```Javascript
var tableService = storage.createTableService();
tableService.createTableIfNotExists('tasktable', function(error){
    if(!error){
        // Table exists
    }
});
```
A new entity can be added by calling **insertEntity**:

```Javascript
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:

```Javascript
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:

```Javascript
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:

```Javascript
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:

```Javascript
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.

```Javascript
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:

```Javascript
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:

```Javascript
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.

```Javascript
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

- [Microsoft Azure SDK for Node.js](https://github.com/WindowsAzure/azure-sdk-for-node)
- [Microsoft Azure SDK for Node.js - Storage Blob](https://github.com/WindowsAzure/azure-sdk-for-node/tree/master/lib/services/blob)
- [Microsoft Azure SDK for Node.js - Storage Table](https://github.com/WindowsAzure/azure-sdk-for-node/tree/master/lib/services/table)
- [Microsoft Azure SDK for Node.js - Storage Queue](https://github.com/WindowsAzure/azure-sdk-for-node/tree/master/lib/services/queue)


![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-node%2Flib%2Fservices%2FlegacyStorage%2FREADME.png)

---
_Source: https://npm.io/package/azure-storage-legacy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
