I have an app where each user's misc files (mostly images) are stored in a separate blob container in an Azure storage account.
The file storage/access is not a major part of the app (it's more of an accessory), but I'd like to monitor each container for potential excessive usage/abuse (storage size, transaction, and bandwidth usage).
Is there a way to achieve this using the native Azure tools/API? Most of the doc I found are on the account level.
Presently there is No native tool for Container level monitoring as per your scenario! Calculating size of Container, Storage Account and Blobs is possible through Azure Storage Explorer, For Transactions, Performance you can refer to Azure Application Insights( It will automatically detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. It's designed to help you continuously improve performance and usability., related to bandwidth we don't store those information's
This article uses the Azure Blob Storage inventory feature and Azure Synapse to calculate the blob count and total size of blobs per container. These values are useful when optimizing blob usage per container. Calculate blob count and total size per container using Azure Storage inventory
$storageAccountName = "xxxx"
$StorageAccountKey = "xxxx"
#get context
$ctx = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $StorageAccountKey
$MaxReturn = 100
$Token = $Null
do
{
#get Containers
$storageContainer = Get-AzureStorageContainer -Context $ctx -MaxCount $MaxReturn -ContinuationToken $Token
$lengthSA = 0
if($storageContainer.Length -le 0) { Break;}
# get a list of all of the blobs in the container
foreach($c in $storageContainer)
{
$cname = $c.Name
$length = 0
$bMaxReturn = 100
$bToken = $Null
do
{
# get a list of all of the blobs in the container
$listOfBlobs = Get-AzStorageBlob -Container "$cname" -Context $ctx -MaxCount $bMaxReturn -ContinuationToken $bToken
if($listOfBlobs.Length -le 0) { Break;}
foreach($blob in $listOfBlobs) {
write-host "Blob name:"
write-host $blob.Name"("$cname" ) container"
write-host "Blob size:"
write-host $blob.length"("$cname" ) container"
$length = $length + $blob.length
}
$bToken = $blob[$blob.Count -1].ContinuationToken;
}while ($bToken -ne $Null)
write-host "The container " $cname " size is $length bytes."
$lengthSA = $lengthSA + $length
}
write-host "The Storage Account " $storageAccountName " size is $lengthSA bytes."
$Token = $c[$c.Count -1].ContinuationToken;
}while ($Token -ne $Null)
If you want to have native query experience on storage logs, you are recommended to use Azure resource logs for Storage. It’s new logging service and has native integration with Log Analytics where you can query logs in Portal.
Reference: Monitoring Azure Blob storage | Microsoft Docs Azure Blob storage monitoring data reference | Microsoft Docs
If you are looking for this specific feature, If you wish you can leave your feedback hereAll the feedback you share in these forums will be monitored and reviewed by the Microsoft engineering teams responsible for building Azure.