从 Azure Powershell 查询 Azure 存储帐户指标
Query Azure Storage Account metrics from Azure Powershell
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 中容器的数量。
- 数一数这些容器中的文件数量。
- Return所有文档的文件存储大小。
- Return指定日期范围内文档的文件存储大小。
这可以从 Azure Powershell 实现吗?
谢谢。
获取容器数量
(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") }
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 中容器的数量。
- 数一数这些容器中的文件数量。
- Return所有文档的文件存储大小。
- Return指定日期范围内文档的文件存储大小。
这可以从 Azure Powershell 实现吗?
谢谢。
获取容器数量
(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") }