Let Azure Storage get_blob_properties() return part of the properties
See original GitHub issueTesting env:
azure-core==1.24.0
azure-storage-blob==12.10.0
Operating System: Ubuntu, Mac OS
Azure Storage blob related APIs provide a function called get_blob_properties
to return the properties of a blob.
We are using it to poll a blob to check its current properties (e.g. blob size). However, we find that there is no way to define what selected property fields to return. The whole returned property dictionary is pretty big (like 1k~2k), which is not very optimized for our usage scenario. Here below is a simplest code snippet to show our usage scenario.
Would you give get_blob_properties
a new parameter to select the returned property fields? Like get_blob_properties(... selected_properties=['creation_time', 'size'])
from azure.storage.blob import BlobServiceClient
CONNECTION_STR = 'DefaultEndpointsProtocol=https;AccountName={};AccountKey={};EndpointSuffix=core.windows.net'
ACCOUNTNAME = 'storems365def'
ACCOUNTKEY = "************key_masked************"
CONTAINERNAME = "insights-logs-advancedhunting-emailevents"
BLOBNAME = "tenantId=8ab4b9aa-f07b-4927-a103-c20e857620a8/y=2022/m=10/d=07/h=22/m=00/PT1H.json"
blob_service_client_instance = BlobServiceClient.from_connection_string(
CONNECTION_STR.format(ACCOUNTNAME, ACCOUNTKEY))
blob_client_instance = blob_service_client_instance.get_blob_client(
CONTAINERNAME, BLOBNAME)
# The returned blob_properties is 1k~2k big. We need to make this call multiple times.
blob_properties = blob_client_instance.get_blob_properties()
# We only want these two fields below
print(blob_properties['size'])
print(blob_properties['creation_time'])
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Get Blob Properties (REST API) - Azure Storage
The Get Blob Properties operation returns all user-defined metadata, standard HTTP properties, and system properties for the blob.
Read more >Set Blob Properties (REST API) - Azure Storage
Subsequent calls to Get Blob Properties will not return this property, unless it is explicitly set on the blob again.
Read more >Get Properties of storage blobs returning empty dict
I've calculated this for my local copy of the files, but am having problems fetching ContentMD5 from Azure. So far, I get an...
Read more >BlobProperties Class (Microsoft.Azure.Storage.Blob)
Initializes a new instance of the BlobProperties class based on an existing instance. Properties. AppendBlobCommittedBlockCount. If the blob is an append blob, ...
Read more >Get Blob (REST API) - Azure Storage - Microsoft Learn
The Get Blob operation reads or downloads a blob from the system, including its metadata and properties. You can also call Get Blob...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @yedeng-anomali! That is the best place for this type of request. I will go ahead and close this issue.
Hi @yedeng-anomali - Thanks for opening an issue! Directing this to the right people.