如何使用Powershell从订阅中计算所有Azure存储表的大小。
我尝试在线搜索是否有任何直接的查询表大小的方法,但看起来没有。 有人可以给我一个计算Azure存储表大小的工作模型吗?
请。
List<Customer> customers = Enumerable.Range(0, 10).Select(c =>
new Customer
{
Name = "Pedro",
Age = "20",
Products = Enumerable.Range(0, 3).Select(p => new Product
{
Code = "1",
Price = "400.00"
}).ToArray()
}).ToList();
答案 0 :(得分:0)
您可以计算所有Azure存储表的大小,但是最小粒度可以只是存储帐户中的所有表,而不是特定的表。
尝试以下命令,对我来说效果很好。
$StorageAccounts = Get-AzStorageAccount
foreach($item in $StorageAccounts){
$id = $item.Id+"/tableServices/default"
$name = $item.StorageAccountName
$metric = Get-AzMetric -ResourceId $id -MetricName "TableCapacity" -WarningAction Ignore
$data = $metric.Data.Average/1024/1024
Write-Output "Tables in $name : $data MB"
}
此外,看起来您想在多个订阅中使用该命令,如果是这样,我认为您需要先运行Set-AzContext
来设置订阅,然后再运行上述命令。
Set-AzContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"