question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Let Azure Storage get_blob_properties() return part of the properties

See original GitHub issue

Testing 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:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jalauzon-msftcommented, Nov 3, 2022

Thanks @yedeng-anomali! That is the best place for this type of request. I will go ahead and close this issue.

1reaction
swathipilcommented, Oct 27, 2022

Hi @yedeng-anomali - Thanks for opening an issue! Directing this to the right people.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found