How to upload stream with Azure.Storage.Blobs

Viewed 4934

I’m trying to upload/store data into an azure blob. The data is generated from a xmlSerialize object. Since the result can be big and I don’t need the serialized output in my program I would like to stream the data directly into the blob. This has been solved with Microsoft.Azure.Storage.Blob : uploading-datatable-to-azure-blob-storage But I’m using Azure.Storage.Blobs since Microsoft is recommending it and the other has been replaced. Also it supports auth with Identity.

The previews solution relied on getting the stream object for the blob so it could be used by the serializer. But I don’t see any way to do the same with the new API. Am I missing something?

2 Answers

But I don’t see any way to do the same with the new API. Am I missing something?

You're correct. Getting a stream object for the blob is not available in the new SDK. You will need to convert the data into stream and then use Upload or UploadAsync method on BlobClient or BlockBlobClient to upload the blob.

Related