Azure-sdk-for-net: Synchronous CloudBlockBlob UploadFrom... ASP.NET Regression 9.3.3 → 9.4.0+ for files ≥ 256MB

Created on 24 Jul 2019  Â·  3Comments  Â·  Source: Azure/azure-sdk-for-net

Describe the bug
There is a defect or undocumented regression when migrating from 9.3.3 (NuGet package Microsoft.WindowsAzure.Storage) to 9.4.0+ (NuGet package Microsoft.Azure.Storage.Blob and Microsoft.Azure.Storage.Common).

This involves all of the synchronous upload endpoints as below:

  • UploadFromStream
  • UploadFromByteArray
  • UploadFromFile
  • UploadFromText

Previously this worked as expected in both console applications and ASP.NET Web API. However, since 9.4.0, calls block endlessly.

This can be circumvented by wrapping in the following code, but should either be documented or fixed.

Task.Run(() => blockBlob.UploadFrom....()).Wait();

Exception or Stack Trace
No stack trace as error not produced, just blocks endlessly.

To Reproduce
Checkout the GitHub repository here and follow the steps to reproduce. It is using .NET 4.6.2 as this is where it was originally discovered.

https://github.com/deenairn/azureblobupload

Code Snippet

Code snippet from above repository. Check repo for more details and contact me if cannot reproduce or compile repo.

            var storageAccount = CloudStorageAccount.Parse(storageAccountName);
            var blobClient = storageAccount.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference(containerName);
            container.CreateIfNotExists();

            var fileName = Path.GetFileNameWithoutExtension(filepath);

            var blockBlob = container.GetBlockBlobReference($"{fileName}-{nameof(UploadFromStream)}-{Guid.NewGuid()}");

            var stream = File.OpenRead(filepath);
            blockBlob.UploadFromStream(stream);

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
N/A

Setup (please complete the following information):

  • OS: Windows
  • IDE : Visual Studio 2019
  • Version of the Library used: .NET Framework 4.6.2, Microsoft.Azure.Storage.Blob 9.4.0+

Additional context
N/A

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x] Bug Description Added
  • [x] Repro Steps Added
  • [x] Setup information Added
Client Service Attention Storage bug customer-reported

Most helpful comment

Thanks, @deenairn. We'll look into adding a section in the v11 library's readme regarding async deadlocks.

The internal code problem is a sync-over-async situation imposed by the HttpClient. We've recently uncovered and addressed one class of issues with the recent v11 release (there were some awaits that didn't also use ConfigureAwait(false)).

All 3 comments

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithub

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithub

Thanks, @deenairn. We'll look into adding a section in the v11 library's readme regarding async deadlocks.

The internal code problem is a sync-over-async situation imposed by the HttpClient. We've recently uncovered and addressed one class of issues with the recent v11 release (there were some awaits that didn't also use ConfigureAwait(false)).

Was this page helpful?
0 / 5 - 0 ratings