How to import Azure BlobService in python?
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.
If you want to use BlobService
, you could install package azure.storage 0.20.0
, there is BlobService
in that version. In the latest azure.storage 0.30.0
, BlobSrvice is split into BlockBlobService, AppendBlobService, PageBlobService
object, you could use BlockBlobService
replace BlobService
.
I had the same issue after using pip to install the azure package and, as the chosen answer suggests, this can be fixed by installing azure.storage 0.33.0.
However, if you're using pip, you might need to use the "--upgrade" option for it to install properly (this was my experience):
pip install azure-storage --upgrade