How to fix ClientAuthenticationError when accessing the parquet (PyArrow) file through Blob Storage?

Wei Zhang 40 Reputation points

HI everyone

When I tried to build a blob client to access one .parquet file in Blob datastore with following script:

import os  
from import   BlobServiceClient  
import pandas as pd  
from io import BytesIO  

connection_str = "*****"
container = "*****"
blob_path = "./source/****.parquet"

blob_service_client = BlobServiceClient.from_connection_string(connection_str)
blob_client = blob_service_client.get_blob_client(container = container, blob = blob_path) 
stream_downloader = blob_client.download_blob()  #error happened here

stream = BytesIO() 
df = pd.read_parquet(stream, engine = 'pyarrow') 

It showed the following error message for this step:


ClientAuthenticationError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:* Time:2024-03-20T20:40:44.8529867Z ErrorCode:AuthenticationFailed authenticationerrordetail:The MAC signature found in the HTTP request '****' is not the same as any computed signature. Server used following string to sign: 'GET

Could someone have a clue about this? Thank you

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,420 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anand Prakash Yadav 5,525 Reputation points Microsoft Vendor

    Hello Wei Zhang,

    Thank you for posting your query here!

    The ClientAuthenticationError you’re encountering typically indicates an issue with the connection string or the way it’s being used to authenticate your requests. Please check the following:

    · Ensure that the connection string is correct. It should be in the format DefaultEndpointsProtocol=https;AccountName=<your-account-name>;AccountKey=<your-account-key>; Please replace <your-account-name> and <your-account-key> with your actual Azure Storage account name and key.

    · The blob path should be the exact path of the blob in the container. For example, if your blob is in a folder named source in your container, the blob path should be source/yourfile.parquet. It should not start with ./.

    · When you download the blob, you need to read the content into the BytesIO stream. Here’s how you can do it:

    stream_downloader = blob_client.download_blob()
    stream = BytesIO()
    df = pd.read_parquet(stream, engine='pyarrow')

    In the above code, stream.write(stream_downloader.readall()) writes the downloaded blob content into the stream, and resets the stream position to the beginning so that pd.read_parquet can read from it


    Do let us know if you have any further queries. I’m happy to assist you further.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful