Connect China Azure Storage Blob By Container Token In Python SDK

简介:

基于Python SDK,使用Container Token操作container对象。关于Token的生成可以使用Storage SDK创建,也可以使用工具快速创建供测试。


示例代码:

from azure.storage.blob import BlockBlobService

account_name = 'yunewstoragetest'
container_sas_token = 'st=2018-05-21T02%3A10%3A00Z&se=2018-05-28T02%3A10%3A011&sp=rwdl&sv=2017-04-17&sr=c&sig=VBE1dvtovwliNGW0tfK2NuPHqBhTX4S7Jm5tNsRZnnM%3D' block_blob_service = BlockBlobService(account_name=account_name, sas_token=container_sas_token, endpoint_suffix="core.chinacloudapi.cn") blob_list = block_blob_service.list_blobs('aaaaa') for blob in blob_list:
print(blob.name)

测试结果

C:\Users\yuvmtest\PycharmProjects\AzureDemo\venv\Scripts\python.exe C:/Users/yuvmtest/PycharmProjects/AzureDemo/AzureStorageDemo/SASDemo.py
$Default/0
$Default/1
++.jpg
+刘亦菲.jpg
Debug.rar
GetStartedWindowsUniversal.rar
Img222232825.jpg
Md5Test.rar
MyFirstApp.rar
app-debug.apk
cmake-2017.rar
cmake-vs2015.rar
cmake.rar
liu3.jpg
pics/1/shuang1.jpeg
pics/1/shuang2.jpg
pics/liu1.jpg
pics/liu2.jpg
刘亦菲.jpg
hello Process finished with exit code 0

参考链接

azure-storage-python

上一篇:劳动节脑洞大开!利用Debug API 获取 加壳客户端的MD5值


下一篇:Shell第二篇:正则表达式和文本处理工具