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.
If you are getting this error:
This request is not authorized to perform this operation using this permissionyou need to provide enough permission to storage account like
storage blob data contributororstorage blob data ownerthen you can fix this issue.As per MS document:
Adding role-assignments follow below steps: