Posted by Arjun on Wednesday 12th December 2018

Node js - Download files from Azure Storage to local File system.

How to Azure Blob

<code>const azureStorage = require('azure-storage');
const path = require('path');
const azureStorageConfig = {
    accountName: "",
    accountKey: "",
    blobURL: "",
    containerName: ""
};
const downloadBlob = async (blobName, downloadFilePath) => {
    return new Promise((resolve, reject) => {
        const name = path.basename(blobName);
        const blobService = azureStorage.createBlobService(azureStorageConfig.accountName, azureStorageConfig.accountKey); 
        blobService.getBlobToLocalFile(azureStorageConfig.containerName, blobName, `${downloadFilePath}${name}`, function(error, serverBlob) {
            if (error) {
                reject(error);
            } else {
                resolve(downloadFilePath);
            }
        });
    });
};
downloadBlob('images/6350402094004393-11.jpeg','./downloads/');</code>