AzureStorageExplorer
AzureStorageExplorer copied to clipboard
Unable to view folder containing blob created from Azure Function using [Blob] output to Azurite
Preflight Checklist
- [X] I have installed the latest version of Storage Explorer.
- [X] I have checked existing resources, including the troubleshooting guide and the release notes.
- [X] I have searched for similar issues.
Storage Explorer Version
1.25.0
Regression From
No response
Architecture
i86
Storage Explorer Build Number
20220803.8
Platform
Windows
OS Version
Windows 10
Bug Description
After writing a blob to a folder in Azurite from an Azure Function project using the [Blob] attribute from Microsoft.Azure.Webjobs.Extensions.Storage.Blobs version 5.0.1, Storage Explorer is unable to list blobs in that folder giving the error The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined. The blob can be successfully read using other methods, such as the [Blob] attribute in read mode in a subsequent function invocation. The issue does not occur with actual storage accounts in Azure using the same code with only connection strings changed.
Steps to Reproduce
- Create a function app project with a reference to Microsoft.Azure.Webjobs.Extensions.Storage.Blobs version 5.0.1
- Configure a connection called 'TestConnection' to use development storage (
UseDevelopmentStorage=true) - Run Azurite so it's listening on default ports
- Create a blob container in Azurite called
testcontainer - Add a function with the following code:
[FunctionName("TestBlob")] public void CreateBlob( [HttpTrigger(Microsoft.Azure.WebJobs.Extensions.Http.AuthorizationLevel.Anonymous, "get", Route = "createblob")] HttpRequest req, [Blob("testcontainer/1.txt", FileAccess.Write, Connection = "TestConnection")] Stream testBlob) { var bytes = Encoding.UTF8.GetBytes("hello world"); testBlob.Write(bytes, 0, bytes.Length); } - Run the function in the debugger and call it
- Open Azure Storage Explorer and navigate to testcontainer
Actual Experience
An error is shown:
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
Expected Experience
I am able to view the created blob and download it
Additional Context
No response
This is a known issue to us. The root cause is a combination of Azurite doesn't return empty MD5 hash values and the JavaScript SDK we use assumes the MD5 hash value is always returned. To workaround this issue, you can write some code to commit the correct MD5 hash of the blob in Azurite. The JavaScript SDK has made a fix in their latest version to gracefully handle missing MD5 hash values but we are a little behind so it will have to wait until our 1.26.0.
Related issue: https://github.com/Azure/Azurite/issues/1592
Thank you - it turned out to be barely even any code to have the MD5 calculated - changing to using a BlobClient instead of a Stream as the bound parameter and using Upload (or UploadAsync). For any who hit this issue and find this, I found the workaround through Azure Blob storage output binding for Azure Functions and then Azure WebJobs Storage Blobs client library for .NET documentation for an example of using BlobClient.
[FunctionName("TestBlob")]
public void CreateBlob(
[HttpTrigger(Microsoft.Azure.WebJobs.Extensions.Http.AuthorizationLevel.Anonymous, "get", Route = "createblob")] HttpRequest req,
[Blob("testcontainer/1.txt", FileAccess.ReadWrite, Connection = "TestConnection")] BlobClient testBlob)
{
var bytes = Encoding.UTF8.GetBytes("hello world");
testBlob.Upload(new BinaryData(bytes));
}
Not sure why it sets the MD5 in BlobClient.Upload and not when bound directly to a stream - I did test calling Upload with a stream instead of BinaryData as well - but that's not really something for this project.
@JasonYeMSFT do we want to dedicate this issue (or a separate one) to making sure we update our blob SDK in 1.26?
@MRayermannMSFT Yes. I will make sure to upgrade the blob SDK in 1.26.0
I also encounter this issue, when writing blob using .NET SDK 12, and connect to the local blob storage
The same - Storage Explorer version 1.25.1 with azurite https://stackoverflow.com/questions/73765729/upload-file-with-azure-blob-storage-output-binding-for-azure-functions
@JasonYeMSFT since you added the merged label days ago, could you please point us what is the commit on the patch applied, thanks !, or how can we get beta azurite with those changes ?
thanks !
@DavidNorena We merged the version update to our next 1.26.0 dev branch. Unfortunately it is not open sourced so you will need to upgrade when it releases. I will update this thread when 1.26.0 become available.
This seems to be fixed in the new v1.26.0 release, but does not yet appear in the query for fixed issues in the release notes, as this issue is still open.
1.26.0 has been released which upgraded the blob SDK to resolve this issue.