High-level API for Azure Blob Storage operations.
Uses the @azure/storage-blob SDK
npm i --save @vtfk/azure-storage-blob
Currently it only supports Shared Access Signature (SAS). Pull requests welcome!
Go to https://portal.azure.com
Storage accounts -> Your Storage account -> Shared access signature
Generate a SAS with desired start
and end
time.
Copy and use Blob service SAS URL
as connectionString
const storage = require('@vtfk/azure-storage-blob')({
connectionString: '<BLOB_SERVICE_SAS_URL>'
/* optional timeout in ms
timeout: 30 * 1000
*/
})
const { containerItems } = await storage.list()
await storage.create('containername')
await storage.remove('containername')
First, connect to the desired container
const container = storage.container('containername')
const { segment: { blobItems } } = await container.list()
await container.writeText('test.json', JSON.stringify({ text: 'One thought fills immensity.' }))
const content = await container.read('test.json')
await container.remove('test.json')
To run example.js
create file .env
in project root with following content
BLOB_SERVICE_SAS_URL=<BLOB_SERVICE_SAS_URL>
And run npm run example