How do I save byte arrays i.e. byte[] to Azure Blob Storage?

This used to be in the Storage Client library (version 1.7 for sure) - but they removed it in version 2.0

"All upload and download methods are now stream based, the FromFile, ByteArray, Text overloads have been removed."

http://blogs.msdn.com/b/windowsazurestorage/archive/2012/10/29/windows-azure-storage-client-library-2-0-breaking-changes-amp-migration-guide.aspx

Creating a read-only memory stream around the byte array is pretty lightweight though:

byte[] data = new byte[] { 1, 2, 3 };
using(var stream = new MemoryStream(data, writable: false)) {
    blockBlob.UploadFromStream(stream);
}

Update: UploadFromByteArray is back

MSDN documentation - from what I can tell in the source code, this came back for version 3.0 and is still there for version 4.0.


Using the new SDK azure.storage.blob

var blobContainerClient = new BlobContainerClient(storageConnectionString, containerName);
BlobClient blob = blobContainerClient.GetBlobClient(blobName);

using(var ms = new MemoryStream(data, false))
{
     await blob.UploadAsync(ms);
}

update:

UploadFromByteArray is back.

public void UploadFromByteArray (
    byte[] buffer,
    int index,
    int count,
    [OptionalAttribute] AccessCondition accessCondition,
    [OptionalAttribute] BlobRequestOptions options,
    [OptionalAttribute] OperationContext operationContext
)

http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.blob.cloudblockblob.uploadfrombytearray.aspx