问题
I have Azure container where i keep some files. I need to access them using python code I did same thing in JAVA but i am unable to replicate it in Python
//This is java code for same.
CloudBlobContainer Con = new CloudBlobContainer("Some SAS URI");
CloudBlockBlob blob1 = Con.getBlockBlobReference(fileName);
blob1.downloadToFile(filePath+fileName+userName);
回答1:
There is no equivalent method in python, you can take a look at the Container class of python
You should always use BlockBlobService with sas token(if you have a sas uri, you can get sas token from it) or account key, like below if you use sas token:
from azure.storage.blob import BlockBlobService
blobservice = BlockBlobService("storage_account",sas_token="?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-04-24T10:01:58Z&st=2019-04-23T02:01:58Z&spr=https&sig=xxxxxxxxx")
blobservice.get_blob_to_path("container_name","blob_name","local_file_path")
来源:https://stackoverflow.com/questions/55794030/download-file-from-azure-blob-container-using-sas-uri-in-python