0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AzureCLI で az storage 内コンテナの容量を量る

Last updated at Posted at 2025-10-02
az storage blob list --container-name <container名> --account-name <account名> --account-key <Key> | jq '[.[].properties.contentLength] | add'

az storage blob list --container-name <container名> --account-name <account名> --account-key <Key> --query "sum([].properties.contentLength) "

image.png

というメモ。

az storage blob | Microsoft Learn
Azure CLI でブロック BLOB を管理する - Azure Storage | Microsoft Learn

AzureCLI – az storage blob – を試してみた。 | あっつんブログ

以下なども。

# パラメータ設定
$accountName = "<account名>"
$containerName = "<container名>"

# BLOB 一覧を取得して JSON としてパース
$blobs = az storage blob list `
    --account-name $accountName `
    --container-name $containerName `
    --auth-mode login `
    --output json | ConvertFrom-Json

# 各 BLOB の contentLength を取り出して合計
$totalSize = 0
foreach ($blob in $blobs) {
    $totalSize += $blob.properties.contentLength
}

# 結果を表示(バイト単位)
Write-Output "Total size: $totalSize bytes"

# MB/GB に変換して表示(任意)
$sizeMB = [math]::Round($totalSize / 1MB, 2)
$sizeGB = [math]::Round($totalSize / 1GB, 2)

Write-Output "Total size: $sizeMB MB"
Write-Output "Total size: $sizeGB GB"

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?