Azure - ADlsError / WebHDFS error while deleting ADLS file

前端 未结 1 428
别那么骄傲
别那么骄傲 2020-12-12 06:35

I am using C# for ADLS authentication and wants to do some file operation like delete, rename. Using below code for authentication and delete operation

var c         


        
相关标签:
1条回答
  • 2020-12-12 07:02

    If we don't assgin permission for our file then we will have no permission to operate the file. If it is that case, please refer to my demo. The following is my detail steps and sample code. It works correctly for me.

    Assign permission for the file on the Azure portal.

    1.In our Data Lake Store account blade, click Data Explorer

    2.click the file or folder for which you want to provide access to the Azure AD application, and then click Access

    3.Add "assign permission" ,in Select User or Group blade, look for the Azure Active Directory application you created earlier. 4.select appropriate permission
    5.Check the file has got permission

    Demo Code:

     var applicationId = "Application Id";
     var secretKey = "Secret Key";
     var tenantId = "Tenant Id";
     var adlsAccountName = "ADLS Account Name";
     var creds = ApplicationTokenProvider.LoginSilentAsync(tenantId, applicationId, secretKey).Result;
     var adlsFileSystemClient = new DataLakeStoreFileSystemManagementClient(creds);
     var status = adlsFileSystemClient.FileSystem.GetFileStatus(adlsAccountName, "/mytempdir/myinputfile.txt");
     var deletResult = adlsFileSystemClient.FileSystem.Delete(adlsAccountName, "/mytempdir/myinputfile.txt");
    

    Delete file

    Get file status

    0 讨论(0)
提交回复
热议问题