How to fix "Failed to upload block This request is not authorized to perform this operation." error while writing a csv to ADLS Gen2 using synapse notebook

Pranav Babu - O365 Admin Account 0 Reputation points
2025-01-30T21:07:29.7933333+00:00

I am trying to write a dataframe into a csv file on ADLS Gen2 using Synapse Notebook. I am using pandas to_csv as below. The 'linkedService': 'xxxxx' uses system assigned managed identity which has the "Storage Blob Data Contributor" role assigned in the storage account. I also added ACL permissions to Read , write , execute on the container and the folder. However, I get the below error :

RuntimeError: Failed to upload blockThis request is not authorized to perform this operation. RequestId:33846b49-b01e-0070-5058-73ab3c000000 Time:2025-01-30T20:51:57.2522522Z ErrorCode:AuthorizationFailure Content: <?xml version="1.0" encoding="utf-8"?><Error><Code>AuthorizationFailure</Code><Message>This request is not authorized to perform this operation. RequestId:33846b49-b01e-0070-5058-73ab3c000000 Time:2025-01-30T20:51:57.2522522Z</Message></Error>!

Please advise on how to fix the error

df.to_csv('abfss://<container>@<accountname>.dfs.core.windows.net/x/abc.csv', storage_options={'linkedService': 'xxxxx'})
		
Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,537 questions
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,164 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Chandra Boorla 7,490 Reputation points Microsoft Vendor
    2025-01-30T22:39:38.8433333+00:00

    Hi @Pranav Babu - O365 Admin Account

    Greetings & Welcome to Microsoft Q&A forum! Thanks for posting your query!

    The AuthorizationFailure error typically indicates a permissions issue or a misconfiguration in accessing Azure Data Lake Storage Gen2 (ADLS Gen2). Even though the system-assigned managed identity has the "Storage Blob Data Contributor" role and ACL permissions.

    Could you please validate if your storage account is enabled with Firewall?

    Change the default network access rule to allow access from all networks:

    Select the storage account you want to access on your Azure dashboard --> Scroll down to Security + networking and select Networking under it --> Select Enable from all networks and click Save to apply changes.

    User's image For more details, please refer the similar thread on Microsoft Q&A platform.

    https://learn.microsoft.com/en-us/answers/questions/1166011/getting-a-403-error-when-connecting-to-a-blob-cont

    For additional information, please refer the following link:

    https://windowsreport.com/microsoft-windows-azure-storage-request-not-authorized-to-perform-operation/

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    I hope this information helps. Please do let us know if you have any further queries.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.

    Thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.