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

4

我刚开始接触Azure和Powershell,我使用了以下脚本连接到我的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

我现在希望查询存储账户以:

  • 计算Blob中容器的数量。
  • 计算这些容器中文档的数量。
  • 返回所有文档的文件存储大小。
  • 返回指定日期范围内文档的文件存储大小。

Azure Powershell是否能够实现此功能?

谢谢。

1个回答

4

获取容器数量

(Get-AzureStorageContainer).Count

获取容器中blob的数量

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

不确定您是想要每个文件的文件大小还是总体大小。

可以使用Get-AzureStorageBlob -Container "ContainerName"来显示每个blob的大小,其中列出了 Length 属性。 Length 是 blob 的字节大小。

要检索总文件大小,请执行以下操作

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

要获取在特定日期范围内最后修改的文件,只需执行以下操作:
Get-AzureStorageBlob -Container "ContainerName" | where { $_.LastModified -gt (Get-Date -Date "specific date") -and $_.LastModified -lt (Get-Date -Date "specific date") }

谢谢你,Casey,非常完美。抱歉,我的声望还不到15,无法点赞。 - user6546748

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接