简体   繁体   中英

Query Azure Storage Account metrics from Azure Powershell

New to Azure and Powershell. I used the following script to connect to my Azure subscription and storage account.

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.
  • 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?

Thank you.

Get number of containers

(Get-AzureStorageContainer).Count

Get number of blobs in container

(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. Length is the blob size in bytes.

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") }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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