question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upload blob async frozen when using memory stream, no error

See original GitHub issue

I’m experiencing a problem with Azure.Storage.Blobs 12.4.0 No error, just frozen forever when trying to upload a stream (an in-memory json string) using Azurite.

It seems the server receives the attempt, but does nothing and the API does not throw any error either:

sqlserver_1  | 172.18.0.1 - - [24/Mar/2020:01:38:55 +0000] "PUT /devstoreaccount1/landing/test637206559996473201.json?st=2020-03-23T13%3A57%3A00Z&se=2020-03-25T13%3A57%3A37Z&sp=racwdl&sv=2018-03-28&sr=c&sig=RYDvl1aQeEIY3isg17LGGtx63Krum13gTXgn981cOco%3D HTTP/1.1" - -

Azurite is running, I can access with the Azure Blob Storage Explorer and generate a sas token uri pasted below.

My code:

var fileName = $"test{DateTime.UtcNow.Ticks}.json";
var fileStream = new MemoryStream();
fileStream.Write(Encoding.UTF8.GetBytes("{'foo': 'bar'}"));
var blobContainerClient = new BlobContainerClient("http://127.0.0.1:10000/devstoreaccount1/landing?st=2020-03-23T13%3A57%3A00Z&se=2020-03-25T13%3A57%3A37Z&sp=racwdl&sv=2018-03-28&sr=c&sig=RYDvl1aQeEIY3isg17LGGtx63Krum13gTXgn981cOco%3D");
await blobContainerClient.UploadBlobAsync(fileName, fileStream); //this gets stuck, no error, just frozen there

PS: The Azurite I use for the test is:

version: '3'
services:
    sqlserver:
        image: mcr.microsoft.com/azure-storage/azurite
        restart: always
        ports:
            - 10000:10000
            - 10001:10001
# Run
# docker-compose -f azurite.yml up -d 

Can anybody spot what the issue might be?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (18 by maintainers)

github_iconTop GitHub Comments

5reactions
DarrenClevengercommented, Mar 24, 2020

I was also having this issue. I found that I had to reset the position to 0 to get this to work.

using var ms = new MemoryStream(); 
ms.Write(ASCIIEncoding.UTF8.GetBytes(jsonData));  
ms.Position = 0;
client.UploadBlob(path, ms);
1reaction
pakrymcommented, Mar 30, 2020

Seems like a bug, when the stream position is not reset the expected behavior should be uploading an empty blob, not hanging.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does BlobClient.UploadAsync hang when uploading ...
I'm trying to upload JSON to an Azure blob via a memory stream. When I call UploadAsync my application hangs. If I move...
Read more >
Will not upload to Azure blob storage
This is how I try to upload to Azure. Now I try to upload then there will be no error at all. Thus...
Read more >
Azure Blob Storage on Iot Edge module stops upload ...
We are currently experiencing an issue with the Azure Blob Storage on IoT Edge module. The module is configured to automatically upload files...
Read more >
Dos and Don'ts for Streaming File Uploads to Azure Blob ...
Implement file uploads the wrong way, and you may end up with memory leaks, server slowdowns, out-of-memory errors, and worst of all, unhappy...
Read more >
Using Async, Await, and Task to keep the WinForms UI ...
Using the async/await pattern in WinForms is an easy win, helping prevent one of the most annoying user experiences - a frozen UI....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found