简体   繁体   English

从Azure Powershell查询Azure存储帐户指标

[英]Query Azure Storage Account metrics from Azure Powershell

New to Azure and Powershell. Azure和Powershell的新功能。 I used the following script to connect to my Azure subscription and storage account. 我使用以下脚本连接到我的Azure订阅和存储帐户。

Import-Module "C:\Program Files (x86)\Microsoft SDKs\WindowsAzure\PowerShell\Azure\Azure.psd1"
Import-AzurePublishSettingsFile 'C:\AZURE_POWERSHELL\DETAILS.publishsettings'
Set-AzureSubscription -SubscriptionName subname -CurrentStorageAccount storagename
Select-AzureSubscription -SubscriptionName subname

I wish to query the storage account now to: 我想立即查询存储帐户:

  • Count the number of containers in Blob. 计算Blob中的容器数量。
  • Count the number of documents these containers. 计算这些容器的文档数量。
  • Return the file storage size of all documents. 返回所有文档的文件存储大小。
  • Return the file storage size of documents with a specified date range. 返回具有指定日期范围的文档的文件存储大小。

Is this possible from Azure Powershell? 这可能来自Azure Powershell吗?

Thank you. 谢谢。

Get number of containers 获取容器数量

(Get-AzureStorageContainer).Count

Get number of blobs in container 获取容器中的blob数量

(Get-AzureStorageBlob -Container "ContainerName").Count

Not sure if you want file sizes for each individual file or an aggregate size. 不确定您是希望每个文件的文件大小还是聚合大小。

Individual file sizes can be shown with Get-AzureStorageBlob -Container "ContainerName" which list a Length attribute for each blob. 可以使用Get-AzureStorageBlob -Container "ContainerName"显示单个文件大小,其中列出了每个blob的Length属性。 Length is the blob size in bytes. Length是以字节为单位的blob大小。

Total file size can be retrieved by doing this 这样做可以检索文件总大小

Get-AzureStorageBlob -Container "ContainerName" | %{ $_.Length } | measure -Sum

To get files that were last modified in a specific date range just do 要获取在特定日期范围内上次修改的文件,请执行此操作

Get-AzureStorageBlob -Container "ContainerName" | where { $_.LastModified -gt (Get-Date -Date "specific date") -and $_.LastModified -lt (Get-Date -Date "specific date") }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM