Hi @Saaketh Gunti ,
As per the message mentioned above says that the signature used in the SAS token does not match the expected signature for the request.
Please follow the below suggestions to the issue fixed:
- Please make sure to use the correct
account_name
ingenerate_blob_sas
: You're currently passing theblob_storage_url
as theaccount_name
. However,account_name
should only be the storage account name (e.g., if the blob URL ishttps://myaccount.blob.core.windows.net
, theaccount_name
ismyaccount
). - Since you’re using your MSFT account credentials, please ensure that the correct
tenant ID
is being used. If you're authenticated in a multi-tenant setup, explicitly configure the credential for the required tenant. - Also, please make sure that the
get_user_delegation_key
call succeeds. If it doesn’t, the returned key will be invalid, resulting in the error. You can inspect theuser_delegation_key
object to verify its validity. - Please make sure that the start and expiry times for the SAS token are correctly set. If there's a significant time difference between your local machine and the Azure server, the token might be deemed invalid. It's a good practice to set the start time a few seconds in the past to accommodate any clock drift.
- However, since the error message includes the "String to Sign", please compare the string to the one which Azure expects as which Log the sas_token and user_delegation_key to debug the signature. And ensure all parameters for generating the SAS token match Azure's requirements.
- Also, please make sure to confirm the user or app registered with the
DefaultAzureCredential
has permissions to generate a User Delegation Key and access the storage account. And please ensure thatRole-Based Access Control (RBAC)
permissions are correctly assigned to your account or managed identity (e.g.,Storage Blob Data Contributor
). - If the issue persists, enable Azure Storage Logging for detailed error traces:
- Go to
Storage Account > Diagnostic settings
and enable logging forAuthentication
andRequests
.
- Go to
For additional information, please refer the below:
- Create a service SAS
- Grant limited access to Azure Storage resources using shared access signatures (SAS)
I hope by following the above helps in resolving the issue.
Please let us know in the comments below, if the issue is resolved or still persists. We will be glad to assist you closely.
Please do consider to “up-vote” wherever the information provided helps you, this can be beneficial to other community members.