What is azure-storage?
The azure-storage npm package is a client library for working with Azure Storage services, including Blob, File, Queue, and Table storage. It allows developers to interact with these services programmatically, enabling tasks such as uploading and downloading files, managing queues, and working with table data.
What are azure-storage's main functionalities?
Blob Storage
Blob Storage allows you to store large amounts of unstructured data, such as text or binary data. The code sample demonstrates how to upload a text file to a blob container.
const azure = require('azure-storage');
const blobService = azure.createBlobService();
// Upload a text file to a container
blobService.createBlockBlobFromText('mycontainer', 'myblob', 'Hello, World!', function(error, result, response) {
if (!error) {
console.log('Blob uploaded successfully');
}
});
File Storage
File Storage provides a way to store and access files in the cloud. The code sample shows how to create a file share and upload a text file to it.
const azure = require('azure-storage');
const fileService = azure.createFileService();
// Create a share and upload a file
fileService.createShareIfNotExists('myshare', function(error, result, response) {
if (!error) {
fileService.createFileFromText('myshare', '', 'myfile', 'Hello, World!', function(error, result, response) {
if (!error) {
console.log('File uploaded successfully');
}
});
}
});
Queue Storage
Queue Storage provides reliable messaging for workflow processing and communication between different parts of your application. The code sample demonstrates how to create a queue and add a message to it.
const azure = require('azure-storage');
const queueService = azure.createQueueService();
// Create a queue and add a message
queueService.createQueueIfNotExists('myqueue', function(error, result, response) {
if (!error) {
queueService.createMessage('myqueue', 'Hello, World!', function(error, result, response) {
if (!error) {
console.log('Message added to queue');
}
});
}
});
Table Storage
Table Storage offers a NoSQL key-value store for rapid development using massive semi-structured datasets. The code sample shows how to create a table and insert an entity into it.
const azure = require('azure-storage');
const tableService = azure.createTableService();
// Create a table and insert an entity
const entGen = azure.TableUtilities.entityGenerator;
const task = {
PartitionKey: entGen.String('tasks'),
RowKey: entGen.String('1'),
description: entGen.String('Task 1'),
dueDate: entGen.DateTime(new Date(Date.UTC(2023, 10, 1)))
};
tableService.createTableIfNotExists('mytable', function(error, result, response) {
if (!error) {
tableService.insertEntity('mytable', task, function(error, result, response) {
if (!error) {
console.log('Entity inserted');
}
});
}
});
Other packages similar to azure-storage
aws-sdk
The aws-sdk package is the official AWS SDK for JavaScript, providing a comprehensive set of tools for interacting with AWS services, including S3 for object storage, DynamoDB for NoSQL databases, SQS for message queuing, and more. It is similar to azure-storage in that it provides a way to interact with cloud storage and other services, but it is specific to Amazon Web Services.
google-cloud
The google-cloud package is the official Google Cloud client library for Node.js. It provides tools for interacting with Google Cloud services, such as Google Cloud Storage for object storage, Firestore for NoSQL databases, and Pub/Sub for messaging. Like azure-storage, it offers a way to interact with cloud storage and other services, but it is specific to Google Cloud Platform.
ibm-cos-sdk
The ibm-cos-sdk package is the official SDK for IBM Cloud Object Storage. It provides tools for interacting with IBM's cloud storage services, allowing for operations such as uploading and downloading files, managing buckets, and more. It is similar to azure-storage in that it provides a way to interact with cloud storage, but it is specific to IBM Cloud.
Legacy Azure Storage SDK for JavaScript
This project provides the legacy Node.js package azure-storage
which is browser compatible to consume and manage Microsoft Azure Storage Services like Azure Blob Storage, Azure Queue Storage, Azure Files and Azure Table Storage
Please note, newer packages @azure/storage-blob
, @azure/storage-queue
and @azure/storage-file
are available as of November 2019 and @azure/data-tables
is available as of June 2021 for the individual services. While the legacy azure-storage
package will continue to receive critical bug fixes, we strongly encourage you to upgrade.
Below are a set of links with information on both the latest and legacy packages for the different Storage services from Azure. For more, please read State of the Azure SDK 2021