Describe the bug
The UploadAsync call fails when run in Blazor WebAssembly. Here is my sample code:
public async Task UploadPayload(Stream payload)
{
BlobClient client = new BlobClient("myConnectionString", "container", "bla");
await client.UploadAsync(payload);
}
Expected behavior
The call succeeds
Actual behavior (include Exception or Stack Trace)
I get the following error:
System.Threading.SynchronizationLockException: Cannot wait on monitors on this runtime.
To Reproduce
Create a new Blazor WebAssembly application (3.2. Preview5 version):
<PackageReference Include="Azure.Storage.Blobs" Version="12.4.1" /> packagePages/Counter.razor as follows (Note: replace myConnectionString with a valid Blob storage connection string)/counter page and click the Click Me button@page "/counter"
@using Azure.Storage.Blobs
@using System.IO
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private async Task IncrementCount()
{
using MemoryStream payload = new MemoryStream();
using StreamWriter sr = new StreamWriter(payload);
sr.WriteLine("Sample payload to upload");
sr.Flush();
payload.Position = 0;
// The above code is simply to simulate a payload
BlobClient client = new BlobClient("myConnectionString", "container", "bla");
await client.UploadAsync(payload);
}
}
Environment:
dotnet --info output for .NET Core projects): .NET Core Runtime: 3.1.3Confirmed fixed with a latest Azure.Core build.
Thank you so much for handling this so fast, @pakrym!
Any hints regarding when should I expect this fix to be released?
This Friday the Azure.Core would ship so customers would have a workaround of updating it. I'm not sure if storage would also ship with updated Azure.Core dependency but the probability is high.
@mkArtakMSFT is there an easy way to run our tests in blazor runtime?
Unfortunately there is no easy way at the moment. We currently handle this manually, but the Mono team is working with the infrastructure team to spin up an internal hardware lab, where we will eventually be able to run automated tests against Mono WebAssembly runtime.