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 in Azure by Hannah
• 16,300 points
12 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 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
1,653 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
169 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,141 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
• 56,920 points
1,208 views
0 votes
4 answers

How can I rename a SQL Azure database?

This command serves the purpose ALTER DATABASE [oldname] ...READ MORE

answered Nov 30, 2018 in Azure by Abhinav
419 views
0 votes
1 answer

What is hybrid cloud?

Hybrid cloud is a cloud computing environment which ...READ MORE

answered Feb 8 in Cloud Computing by Aru
31 views
0 votes
2 answers

Hybrid Cloud vs multi-Cloud

Hybrid cloud is an infrastructure while multi-cloud ...READ MORE

answered Feb 8 in Cloud Computing by sarosh
40 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 in Azure by Prerna
• 1,940 points
594 views
0 votes
1 answer

How to create a sub-container in Azure?

You can create a container named "content" and ...READ MORE

answered Jun 28 in Azure by Perry
• 17,020 points
88 views