Prerna Chadha
Prerna Chadha

Reputation: 11

How to work with the blob error in VsCode

enter image description hereThe Error is as shown in the image

enter image description here

Upvotes: 0

Views: 715

Answers (2)

Sampath
Sampath

Reputation: 3478

I followed the below Steps to download the file from the blob storage to local path

  • I tried your code and got the same as yours

enter image description here

  • Adding input to @MingJie-MSFT

  • Create an Azure Storage account, Container and Upload the file

enter image description here

  • In visual studio code enter the below code, give your bloburl and file name.

enter image description here


from fileinput import filename
from azure.storage.blob import BlobServiceClient
from azure.storage.blob import BlobClient


blob_url = "your blob url"
file_name = "hello2.log"

blob_client= BlobClient.from_blob_url(blob_url)
with open(file_name, "wb") as my_blob:
    download_stream= blob_client.download_blob()   
    my_blob.write(download_stream.readall())


  • Run the code

enter image description here

Upvotes: 2

MingJie-MSFT
MingJie-MSFT

Reputation: 9209

The package you imported is incorrect.

The method from_blob_url belong to package BlobClient instead of BlobServiceClient.

enter image description here

from azure.storage.blob import BlobClient
BlobClient.from_blob_url

Upvotes: 0

Related Questions