Showing posts with label azure-data-lake-gen2. Show all posts
Showing posts with label azure-data-lake-gen2. Show all posts

Tuesday, 27 October 2020

Get Azure Data Lake Gen2 Container, Folder Size


Problem


How to get Azure data lake gen 2 container or folder size 

Solution


PowerShell AZ Module has to be installed to run below commands

Run below code to connect to your Azure account

Connect-AzAccount

To get the container total size, specify the container (file system) name in the variable at first line and run the code

$myfilesystem = "adventureworks"

$ctx = New-AzStorageContext -StorageAccountName "vcadlsgen2" -UseConnectedAccount

$Files = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $myfilesystem -Recurse `

            | Where-Object IsDirectory -eq $false

$Total = $Files | Measure-Object -Property Length -Sum

$Total | Select-Object @{Name = "SizeInBytes"; Expression={$_.Sum}},

                       @{Name = "SizeInKB"; Expression={$_.Sum/1KB}}  


Output - 



To get the folder size, specify the container (file system) name as well as folder path in the variable

$myfilesystem = "adventureworks"

$mypath = "Address"

$ctx = New-AzStorageContext -StorageAccountName "vcadlsgen2" -UseConnectedAccount

$Files = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $myfilesystem -Path $mypath -Recurse | Where-Object IsDirectory -eq $false

$Total = $Files | Measure-Object -Property Length -Sum

$Total | Select-Object @{Name = "SizeInBytes"; Expression={$_.Sum}},

                       @{Name = "SizeInKB"; Expression={$_.Sum/1KB}} 


Output -