Nands
Nands

Reputation: 399

Error when try to download file from Azure Data Lake

I tried to download a file from Azure Data Lake. With the credentials, I can list the contents of the directory. But Downloading gives below error: "This request is not authorized to perform this operation using this permission"

The code used:

TokenCredential credential = new ClientSecretCredential(
            tenantID, clientID, clientSecret, new TokenCredentialOptions());
    
string dfsUri = "https://" + accountName + ".dfs.core.windows.net";
               
DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient(new Uri(dfsUri), credential);
    
DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.GetFileSystemClient("DAIP_Data");
    
DataLakeDirectoryClient directoryClient =
                    fileSystemClient.GetDirectoryClient("DAIP/System2");
    
DataLakeFileClient fileClient =
                    directoryClient.GetFileClient("System2_iDoc_20211229182731_06e34fa6-f683-4568-8a5d-5ae30eac50b6.xml");
    
Response<FileDownloadInfo> downloadResponse = await fileClient.ReadAsync();

Any suggestion/ help would be appreciated.

Thanks.

Upvotes: 0

Views: 551

Answers (1)

Vamsi Bitra
Vamsi Bitra

Reputation: 2764

If you are getting this error: This request is not authorized to perform this operation using this permission

you need to provide enough permission to storage account like storage blob data contributor or storage blob data owner then you can fix this issue.

As per MS document:

Ref1

Adding role-assignments follow below steps:

Ref2

Ref3

Upvotes: 0

Related Questions