How to import Azure BlobService in python?

前端 未结 4 1149
名媛妹妹
名媛妹妹 2020-12-06 10:00

We are able to import azure.storage, but not access the BlobService attribute

The documentation says to use the following import statement:

from azur         


        
4条回答
  •  没有蜡笔的小新
    2020-12-06 10:32

    It's possible the library has changed since that tutorial was published, but...

    I just tried this a few moments ago, successfully:

    from azure.storage.blob import BlockBlobService
    
    blob_service = BlockBlobService(account_name="...",account_key="...")
    

    And I installed Azure storage locally via:

    pip install azure-storage
    

    I was able to test this by downloading an object from storage:

    blob_service.get_blob_to_path("containername","blobname","localfilename")
    

    Note: You could import PageBlobService in similar fashion, but you might not find that too valuable, since page blobs are primarily for vhd's.

提交回复
热议问题