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.
Asked
Active
Viewed 1,955 times
2 Answers
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;
}
I also test it with PostMan.

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;

arghtype
- 4,376
- 11
- 45
- 60