0

I followed the azure tutorial in order to upload photos in an azure account storage : https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/

This is my code (exactly the same than the tutorial) :

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()

But when I execute it I have this following exception :

Exception

Can somebody explain me what is the problem ? I contacted the azure support which told me that they couldn't do anything for me ...

In addition, I'm using the recommended python package in the tutorial : https://github.com/Azure/azure-storage-python with the latest version.

2
  • 1
    My guess is that you're providing improper account key. Can you share the value you pass in account_key=UserPhotoBlobStorage.ACCOUNT_KEY? IMPORTANT: PLEASE DO NOT SHARE THE ACCOUNT NAME Commented Jun 14, 2016 at 11:21
  • @GauravMantri is correct: either your account name or key is incorrect. I just ran your exact code with no issues. Commented Jun 14, 2016 at 13:11

1 Answer 1

1

The error is related to your account key being incorrect. The Azure storage key is base64-encoded. The string you provided ("account_key") is not properly base64-encoded, hence the Incorrect padding error. Try running this again with the full account key (either primary or secondary) provided within the portal.

Sign up to request clarification or add additional context in comments.

2 Comments

I regenerated a new set of keys and now it works fine. Thank you everyone
Glad to hear it. Please either mark this answer as such, to properly close the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.