无法使用python创建azure存储容器

时间:2016-06-14 11:15:33

标签: python azure azure-storage azure-storage-blobs

我遵循azure教程,以便在天蓝色帐户存储中上传照片:https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/

这是我的代码(与教程完全相同):

from azure.storage.blob import BlockBlobService
from azure.storage.blob import PublicAccess


class UserPhotoBlobStorage():

    ACCOUNT_NAME = "account_name"
    ACCOUNT_KEY = "account_key"

    def __init__(self):
        self.block_blob_service = BlockBlobService(account_name=UserPhotoBlobStorage.ACCOUNT_NAME,
                                                   account_key=UserPhotoBlobStorage.ACCOUNT_KEY)
        self.block_blob_service.create_container('mycontainer', public_access=PublicAccess.Container)


if __name__ == '__main__':
    storage = UserPhotoBlobStorage()

但是当我执行它时,我有以下异常:

Exception

有人可以解释一下我的问题是什么吗? 我联系了天蓝色的支持,告诉我他们无法为我做任何事......

此外,我使用了教程中推荐的python包:https://github.com/Azure/azure-storage-python和最新版本。

1 个答案:

答案 0 :(得分:1)

该错误与您的帐户密钥不正确有关。 Azure存储密钥是base64编码的。您提供的字符串("account_key")未正确进行base64编码,因此出现Incorrect padding错误。尝试使用门户网站中提供的完整帐户密钥(主要或次要密钥)再次运行此操作。