使用python

时间:2016-09-30 16:29:53

标签: python python-3.x azure

我编写了一个python脚本,用于从Azure存储帐户获取容器中的所有blob。

def single_value(account,key):

blob_service =  BlobService(account_name=account, account_key=key)
next_marker = None
while True:
    file = open('%s.txt'%(account), 'a')
    blobs = blob_service.list_blobs('containername', marker=next_marker)
    next_marker = blobs.next_marker
    try:
       file.write("%s"%blob.name)
       file.write('\n')
       file.close()
       print(len(blobs))
       if not next_marker:
           break
    except Exception as e:
        print('failed to complete the check: {0}'.format(e))

single_value(' storageaccount',' key')

当我执行脚本时,我收到错误

azure.common.AzureHttpError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. 

我无法弄清楚这个问题。

如果我不使用功能,我可以获取检索blob

0 个答案:

没有答案