2

Is there a simple API using which I can get the size of an ADLS directory? preferably something in C#, but it's not a must.

AK_
  • 7,981
  • 7
  • 46
  • 78

2 Answers2

3

We could use the Get Content Summary of a Directory REST API to do that.

curl -i "http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=GETCONTENTSUMMARY"

C# code demo

 var url = "https://tomdatalake.azuredatalakestore.net/webhdfs/v1/tomtest?api-version=2017-08-01&op=GETCONTENTSUMMARY";
 var token = "eyJ0eX.....";
 using (var client = new HttpClient())
 {
     client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
     var result = client.GetAsync(url).Result;
     var data = result.Content.ReadAsStringAsync().Result;
 }

enter image description here

I also test it with PostMan.

enter image description here

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
2

Yes, you can use DataLakeStoreFileSystemManagementClient.FileSystem.GetContentSummary:

var client = new DataLakeStoreFileSystemManagementClient(credentials);
ContentSummaryResult result = client.FileSystem.GetContentSummary(dataLakeAccount, path);
var dirSize = result.ContentSummary.Length;

Documentation.

arghtype
  • 4,376
  • 11
  • 45
  • 60