calculate the length of the storage container - Azure blob storage

0 votes
Hi, I am very new to azure. I have a blob storage container. I want a logic to calculate the length of the storage container. Any help would be nice.

Thank you!
Oct 30, 2019 in Azure by Hannah
• 18,570 points
1,088 views

1 answer to this question.

0 votes

You can use the following code:

$resourceGroup = "bloblisttestrg"
$storageAccountName = "contosobloblisttest"
$containerName = "listtestblobs"

# get a reference to the storage account and the context
$storageAccount = Get-AzStorageAccount `
  -ResourceGroupName $resourceGroup `
  -Name $storageAccountName
$ctx = $storageAccount.Context 

# get a list of all of the blobs in the container 
$listOfBLobs = Get-AzStorageBlob -Container $ContainerName -Context $ctx 

# zero out our total
$length = 0

# this loops through the list of blobs and retrieves the length for each blob
#   and adds it to the total
$listOfBlobs | ForEach-Object {$length = $length + $_.Length}

# output the blobs and their sizes and the total 
Write-Host "List of Blobs and their size (length)"
Write-Host " " 
$listOfBlobs | select Name, Length
Write-Host " "
Write-Host "Total Length = " $length


Hope this helps!

To know more about Azure, It's recommended to join Azure Training in Chennai today.

answered Oct 30, 2019 by Waheem

edited Oct 7, 2021 by Sarfaraz

Related Questions In Azure

0 votes
1 answer

How to get the list of names of Azure blob files in a container?

We can get some additional info like Size, ...READ MORE

answered Jun 27, 2018 in Azure by club_seesharp
• 3,450 points
14,991 views
0 votes
1 answer

How to upload a file on to Azure Blob storage without writing a code?

You can find the below tools useful ...READ MORE

answered Apr 13, 2018 in Azure by club_seesharp
• 3,450 points
808 views
+1 vote
1 answer

Can I rename a Azure Storage Blob?

Though the approach I'm about to share ...READ MORE

answered May 11, 2018 in Azure by club_seesharp
• 3,450 points
7,628 views
0 votes
2 answers

Reading PDF file from Azure blob storage

For pdf reading and manipulating Itextsharp libraby is fine. For ...READ MORE

answered Aug 17, 2018 in Azure by Priyaj
• 58,080 points
5,151 views
0 votes
1 answer

What is azure blob storage?

Azure Blob storage is Microsoft's object storage ...READ MORE

answered Jan 13, 2020 in Azure by Sirajul
• 59,170 points

edited Oct 7, 2021 by Sarfaraz 503 views
0 votes
1 answer

How to upload files to azure?

To access Azure Storage, you'll need an ...READ MORE

answered Jan 21, 2020 in Azure by Sirajul
• 59,170 points
4,993 views
0 votes
1 answer

Azure Blob Storage URL : WASB:// vs HTTP://

wasb://XXXXXXXXXX@XXXXX.blob.core.windows.net is used to access blob storage through ...READ MORE

answered Apr 7 in Azure by Edureka
• 9,540 points
63 views
0 votes
1 answer

How do I stream videos from Azure Blob Storage?

What you are missing is a Shared Access ...READ MORE

answered Apr 25, 2019 in Azure by prerna
• 1,960 points
5,510 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP