0

I want the file storage specifically not the blob storage (I think). This is code for my azure function and I just have a bunch of stuff in my node_modules folder.

What I would like to do is upload a zip of the entire app and then just upload that and have azure unpack it at a given folder. Is this possible?

Right now I'm essentially iterating over all of my files and calling:

var fileStream = new stream.Readable();
fileStream.push(myFileBuffer);
fileStream.push(null);

fileService.createFileFromStream('taskshare', 'taskdirectory', 'taskfile', fileStream, myFileBuffer.length, function(error, result, response) {
  if (!error) {
    // file uploaded
  }
});

And this works its just too slow. So I'm wondering if there is a faster way to upload a bunch of files for use in apps.

justin.m.chase
  • 13,061
  • 8
  • 52
  • 100
  • What happens if you try uploading the files concurrently? – Jacob Krall Oct 03 '17 at 02:52
  • I altered it to do this, but its still way too slow for my expectations. It went from something like 30 minutes to 5 minutes. But it seems like there is a `kudu` api for sending and unpacking zip files. I'm still trying to figure it out and if I manage to I will post results here. – justin.m.chase Oct 04 '17 at 15:38

1 Answers1

0

And this works its just too slow. So I'm wondering if there is a faster way to upload a bunch of files for use in apps.

If Microsoft Azure Storage Data Movement Library is acceptable, please have a try to use it. The Microsoft Azure Storage Data Movement Library designed for high-performance uploading, downloading and copying Azure Storage Blob and File. This library is based on the core data movement framework that powers AzCopy.

We also could get the demo code from the github document.

string storageConnectionString = "myStorageConnectionString";
CloudStorageAccount account = CloudStorageAccount.Parse(storageConnectionString);
CloudBlobClient blobClient = account.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference("mycontainer");
blobContainer.CreateIfNotExists();
string sourcePath = "path\\to\\test.txt";
CloudBlockBlob destBlob = blobContainer.GetBlockBlobReference("myblob");

// Setup the number of the concurrent operations
TransferManager.Configurations.ParallelOperations = 64;
// Setup the transfer context and track the upoload progress
SingleTransferContext context = new SingleTransferContext();
context.ProgressHandler = new Progress<TransferStatus>((progress) =>
{
    Console.WriteLine("Bytes uploaded: {0}", progress.BytesTransferred);
});
// Upload a local blob
var task = TransferManager.UploadAsync(
    sourcePath, destBlob, null, context, CancellationToken.None);
task.Wait();
Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • I'm using nodejs so I can't use this library directly, I'm trying to look into the code and see what api's its using though. I'm also using File not Blob. – justin.m.chase Oct 03 '17 at 13:07