@Qian Huang Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
Based on the error message: AuthenticationFailed
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:8dfa9bd4-f01a-0032-487e-eb8051000000 Time:2023-09-20T04:53:10.5521004ZSignature did not match. String to sign used was r 2023-09-20T05:06:18Z /file/....png 2023-01-03"
Based on the error message you provided, it seems like there might be an issue with the SAS token that you're generating. Here are a few things you can try to resolve the issue:
- Double-check that the
account_name
,share_name
, andfile_path
parameters that you're passing to thegenerate_file_sas
function are correct and match the values in your Azure portal. - Make sure that the
permission
parameter that you're passing to thegenerate_file_sas
function is in the correct format. Thepermission
parameter should be a string that specifies the permissions that you want to grant to the SAS token For example, if you want to grant read and write permissions, thepermission
parameter should be"rwd"
.
- Check that the
expiry_time
parameter that you're passing to thegenerate_file_sas
function is in the correct format. Theexpiry_time
parameter should be adatetime
object that specifies the time when the SAS token will expire. - Verify that the
key
parameter that you're passing to thegenerate_file_sas
function is correct and matches the storage account key in your Azure portal.
Can you try to re-generate the SAS token through Azure Storage Explorer tool or generating a shared access signature (in azure portal) for key2 instead of key1. Changing the key fixed the error. (Settings > Shared access signature) Also the connection string should be updated as well - if used. (Settings > Access keys)and try again
Also to upload or download files to an Azure Storage account, there are several option, Especially easy and the fastest ways is through Azcopy tool
Authorize requests to Azure Storage
Please 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.