简体   繁体   English

如何使用Powershell在Microsoft Azure中获取存储帐户的使用情况

[英]How to get the usage for an storage account in Microsoft azure using powershell

How to get the usage for an storage account in Microsoft azure using powershell. 如何获得使用PowerShell在微软Azure的存储账户的使用

I am able to get the storage accounts present in an subscription. 我能够获得订阅中存在的存储帐户。 But these variables are not exposing any methods by which i can get the usage of an storage account. 但是这些变量并未公开我可以使用的存储帐户的任何方法。

I'd say the easiest way (afaik) would be to enable Storage analytics metrics on the storage account and then fetch and aggregate on the logs. 我想说的最简单的方法(afaik)是在存储帐户上启用存储分析指标,然后在日志上进行获取和汇总。

Example (enable metric on Blob) 示例(在Blob上启用指标)

Set-StorageServicePropertiesForAnalytics -ServiceName "Blob" -StorageAccountName "<Storage Account Name>" -StorageAccountKey "<Storage Account Key>" -MetricsEnabled -MetricsRetentionPolicyDays 7 -MetricsRetentionPolicyEnabled

NB: You have to wait for a while (a day) after enabling the log 注意:启用日志后,您必须等待一段时间(一天)

Then aggregate (and fetch the usage on the storage account after a day or so): 然后汇总(并在一天左右的时间后获取存储帐户的使用情况):

$logName = "C:\tmp\StorageAccount.log"; 
Get-StorageAnalyticsMetrics -DataType "Capacity" -ServiceName "Blob" -LocalPath $logName -StorageAccountName "<StoragE account name"> -StorageAccountKey "<Storage account key>" 
$results = (Import-Csv $logName | Where-Object { $_.Category -eq "data" } | Select-Object -Last 1 @{Name="AccountName";Expression={"My storage account"}}, Time, "Capacity (bytes)", "Container count", "Object count")

$results

Should give you a data set which is easy to display and aggregate on. 应该给您一个易于显示和汇总的数据集。 You could also iterate multiple storage accounts / containers and split this if you want. 您还可以迭代多个存储帐户/容器,并根据需要进行拆分。 This example only fetches for the blob service. 此示例仅获取Blob服务。 You can also get storage analytics used for other services (table/queue etc); 您还可以获取用于其他服务(表/队列等)的存储分析; however as specified in the documentation the capacity metric is only available for the blob storage. 但是,按照文档中的规定,容量指标仅适用于Blob存储。

For more information on storage account analytics and options see here: 有关存储帐户分析和选项的更多信息,请参见此处:

http://msdn.microsoft.com/en-us/library/windowsazure/hh343258.aspx http://msdn.microsoft.com/zh-CN/library/windowsazure/hh343258.aspx

Please note that after enabling the analytics on the Storage account, you'll have to wait before exporting the logs and aggregating on the data. 请注意,在“存储”帐户上启用分析后,您将不得不等待导出日志并汇总数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 powershell 中获取 Azure 存储帐户基础架构加密状态 - How to get Azure storage account Infrastructure encryption status in powershell 使用Powershell将bacpac导出到Azure存储帐户 - Export bacpac to a Azure storage account using powershell 如何使用 azure function 在 Z2F235951F0EA30874 - How to create connection between azure storage account for file reading to AAS using azure function in powershell 使用Powershell删除Azure存储帐户 - remove azure storage account with powershell 无法使用PowerShell在VM上映射Azure存储帐户文件共享 - Cannot get Azure Storage Account File Share mapped on VM using PowerShell Azure Powershell将Azure存储帐户复制到另一个Azure存储帐户 - Azure Powershell to copy azure storage account to another azure storage account 在 Powershell Function 应用程序中获取 Azure 存储帐户密钥 - Get Azure Storage Account Key inside Powershell Function App 如何使用 PowerShell 在 Azure 存储表中获取一行? - How get a row in Azure Storage tables using PowerShell? PowerShell - 使用Microsoft帐户连接到Azure Active Directory - PowerShell - Connecting to Azure Active Directory using Microsoft Account 使用Powershell删除Azure Functionapp及其关联的存储帐户 - Deleting an Azure Functionapp and its associated Storage Account using powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM