3

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 2

2

See answer at https://stackoverflow.com/a/65395088/2589083

new Azure.Storage.Blobs.Specialized.BlockBlobClient(System.Uri uri)

Sign up to request clarification or add additional context in comments.

Comments

2

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.

4 Comments

"You will need to convert the data into stream" you mean storing the result in a MemoryStream or write it into a temp file?
Storing it in memory stream.
Or if you want you can save it in a file. Then you can read the file in chunks and upload them using methods available in BlockBlobClient.
It's possible through IBinder coming from Microsoft.Azure.WebJobs events though. using (var sw = binder.Bind<Stream>(new BlobAttribute(blobNameOut, FileAccess.Write))) using (var writer = new StreamWriter(sw)) { await WriteMethod(streamReader, writer, cancellationToken); } If you know if it's possible to instantiate IBinder with any implementation I'm interested :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.