user6546748
user6546748

Reputation:

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:

Is this possible from Azure Powershell?

Thank you.

Upvotes: 4

Views: 1398

Answers (1)

Casey
Casey

Reputation: 805

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

Upvotes: 4

Related Questions