Read a blob directly without downloading it(python azure sdk

Nate Lo Yih-Shiou 1 Reputation point
2020-07-20T05:26:33.483+00:00

Hello,

If I want to read/revise a blob in a container, do I need to download to vm to read/revise it? Or can I just read/revise it through any other methods like blob service etc?

As I saw the legacy SDK was able to do it like get_blob_to_stream in azure.storage.blob.baseblobservice. Is there new SDK that can achieve the similar results?

Thanks!

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,192 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sumarigo-MSFT 47,466 Reputation points Microsoft Employee Moderator
    2020-07-21T16:27:47.633+00:00

    @Nate Lo Yih-Shiou You have that option ! If you want to read a blob into a stream. There’s an equivalent method in the new version.
    Please refer to this article: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-storage-blob/12.3.2/azure.storage.blob.html#azure.storage.blob.BlobClient.download_blob

    with open(DEST_FILE, "wb") as my_blob:  
        download_stream = blob_client.download_blob()  
        download_stream.readinto(my_blob)  
    

    However, if you want to modify only part of a blob, let's say a block of a block blob. You don't have to download the whole blob then you should be able to update only a block.

    Hope this helps!
    Kindly let us know if the above helps or you need further assistance on this issue.

    -----------------------------------------------------------------------------------------------------------------------------------------

    Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


  2. Akmal Sabri 0 Reputation points
    2024-01-16T08:46:42.85+00:00

    what is DEST_FILE ? file path that we want to download?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.