How can I get a size of container in Azure Storage? I access Azure storage via C# API:
var account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStoragePrimary"]);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference("myContainer");
There's a Calculate size on Azure portal, right click on our container and click Container properties, we can see panel as below. Please let us know if you have any further queries.
No, there's no limit on the number of storage containers in a storage account. You're limited by the size of the storage account which was recently increased to 500 TB from 200 TB .
How to get the size of all Storage Accounts using the Azure portal Log into the Azure portal Select Monitor from the left hand panel or use the search bar at the top Select Storage Accounts from the left hand pane under the Insights section
The 200 TB blob size is available for preview in all Azure public regions with hot, cool, archive, and premium tiers. There are no billing changes. Learn more to get started. Azure Blob Storage Features Back to Azure Updates
2. Calculate the capacity at the single storage account and different service level (Blob/Queue/Table/File) – via Portal. In the Azure portal, select Storage accounts. From the list, choose a storage account. In the Monitoring section, choose Insights (preview).
Inside the Properties view you will have a button at the bottom to “Calculate Size”. Click on this button to get the size of the Container. 8. Now you are presented with the Blob Container Size. Phew we finally got there. So that is how you can get the size of a Container in a Storage Account using the Azure portal.
A potentially more complete approach. The key difference, is the second param in the listblobs() call, which enforces a flat listing:
public class StorageReport
{
public int FileCount { get; set; }
public int DirectoryCount { get; set; }
public long TotalBytes { get; set; }
}
//embdeded in some method
StorageReport report = new StorageReport() {
FileCount = 0,
DirectoryCount = 0,
TotalBytes = 0
};
foreach (IListBlobItem blobItem in container.ListBlobs(null, true, BlobListingDetails.None))
{
if (blobItem is CloudBlockBlob)
{
CloudBlockBlob blob = blobItem as CloudBlockBlob;
report.FileCount++;
report.TotalBytes += blob.Properties.Length;
}
else if (blobItem is CloudPageBlob)
{
CloudPageBlob pageBlob = blobItem as CloudPageBlob;
report.FileCount++;
report.TotalBytes += pageBlob.Properties.Length;
}
else if (blobItem is CloudBlobDirectory)
{
CloudBlobDirectory directory = blobItem as CloudBlobDirectory;
report.DirectoryCount++;
}
}
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStoragePrimary"]);
CloudBlobClient blobClient = account.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference("myContainer");
int fileSize = 0;
foreach (var blobItem in blobContainer.ListBlobs())
{
fileSize += blobItem.Properties.Length;
}
fileSize
contains the size of container, i.e. total size of blobs (files) contained.
Reference: CloudBlob: http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblob_methods.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With