azure-sdk-for-java: Azure Blob - "BlobItem.getMetadata()" returns null but "BlobClient.getProperties().getMetadata()" returns correct value
We are using BlobContainerClient.listBlobsByHierarchy(..) to get list of blobs while iterating we realised that BlobItem.getMetadata() returns null but BlobClient.getProperties().getMetadata() returns correct value
Prerequisite Create a blob which should have metadata
Code Snippet To Reproduce
public void getBlobMetadata() throws Exception {
String containerName = "**-test";
String directoryName = "**-test";
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().endpoint(BLOB_SAS).buildClient();
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient(containerName);
ListBlobsOptions listBlobOption = new ListBlobsOptions();
listBlobOption.setMaxResultsPerPage(10);
listBlobOption.setPrefix(directoryName);
PagedIterable<BlobItem> pagedIterable = blobContainerClient.listBlobsByHierarchy(null, listBlobOption, null);
Iterable<PagedResponse<BlobItem>> iterableByPage = pagedIterable.iterableByPage(10);
Iterator<PagedResponse<BlobItem>> pagedResponseiterator = iterableByPage.iterator();
while (pagedResponseiterator.hasNext()) {
PagedResponse<BlobItem> pagedResponse = pagedResponseiterator.next();
Iterator<BlobItem> pagedBlobItems = pagedResponse.getElements().iterator();
while (pagedBlobItems.hasNext()) {
BlobItem blobItem = pagedBlobItems.next();
LOGGER.info("BlobItem - BlobName '{}', Metadata '{}'", blobItem.getName(), blobItem.getMetadata());
BlobClient blobClient = blobContainerClient.getBlobClient(blobItem.getName());
LOGGER.info("BlobClient - BlobName '{}', Metadata '{}'", blobItem.getName(), blobClient.getProperties().getMetadata());
}
}
}
Expected behavior
BlobItem.getMetadata() should return available metadatas
Screenshots

Setup (please complete the following information if applicable):
OS: window
IDE : eclipse
Version of the Library used: azure-storage-blob-12.10.2
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (11 by maintainers)
Hi @abhikt48 I’ve created an issue tracking this (it isn’t publicly visible but I noted this issue number so whoever picks this item up can update you)
Hi @abhikt48
I spoke with my team. We will take a second look at the properties returned by listBlobs/getProperties and ensure they align with all the service supported properties.
Hi @abhikt48 Thanks for clarifying. I am going to check with other platforms to see how they expose these variables and will get back to you.