none
How to use Azure Python SDK or REST API to get current usage of Blob service for all storage accounts?

    Question

  • When I called the method (referenced in http://azure-storage.readthedocs.org/en/latest/blob.html )

    blob_service.list_containers()

    I got the error:

    in _general_error_handler(http_error)
         80     if http_error.respbody is not None:
         81         message += '\n' + http_error.respbody.decode('utf-8-sig')
    ---> 82     raise AzureHttpError(message, http_error.status)
         83
         84
    
    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.
    RequestId:417d71ca-0001-0040-5f9f-3c5f71000000
    Time:2015-12-22T09:59:09.6438750Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request ‘xxx/xxx+xxx/xxx/xxx=' is not the same as any computed signature. Server used following string to sign: 'GET
    
    
    
    
    application/octet-stream Charset=UTF-8
    
    
    
    
    
    
    x-ms-date:Tue, 22 Dec 2015 09:59:07 GMT
    x-ms-version:2014-02-14
    /myaccount/
    comp:list'.</AuthenticationErrorDetail></Error>
    Any experience here?

    Tuesday, December 22, 2015 10:26 AM

All replies

  • Hi,

    I suggest you to refer the below steps.

    ### List Containers

    This example shows how to list containers of an account. The method ```BlobService.list_containers()``` will return a list of ```Container``` instances, consisting of name, url, properties and metadata.

    ```python
    from azurepython3.blobservice import BlobService
    svc = BlobService.from_config("azurecredentials.json")
    containers = svc.list_containers()

    for c in containers:
    print("%s (%s)" % (c.name, c.url))
    print(c.properties)
    ```

    Refer: https://pypi.python.org/pypi/azurepython3/1.7.7

    Hope this helps.

    Girish Prajwal

    Tuesday, December 22, 2015 5:51 PM
    Moderator