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
• 17,380 points
67 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
answered Oct 30, 2019 by Waheem

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
2,400 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
203 views
+1 vote
1 answer

Can I rename a Azure Storage Blob?

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

answered May 10, 2018 in Azure by club_seesharp
• 3,450 points
1,493 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
• 57,490 points
1,451 views
0 votes
1 answer

What is azure blob storage?

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

answered Jan 13 in Azure by Sirajul
• 45,170 points
14 views
0 votes
1 answer
0 votes
1 answer

How is Azure Cosmos db different from an Azure SQL db?

Azure Cosmos DB is Microsoft’s globally distributed database ...READ MORE

answered Jan 10 in Azure by Sirajul
• 45,170 points
146 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,940 points
1,010 views