I just had to write a script to find all storage accounts with blobs present in a specific subscription in a specific region.
This proved to be non-trivial as the storage account function doesn’t have a region filter, and you have to manually crawl the accounts to see if they’re using blobs.
Here is the fully-working script I came up with, I hope it helps you out!
rm -f accounts_with_blobs.csv
tenant="your-tenant-id"
subscription="your-subscription-name"
region="your-region"
az login --tenant "${tenant}" --subscription "${subscription}"
# Get all subscription + region filtered storage account names.
accounts=$(az storage account list --output table --subscription "${subscription}" | grep "${region}" | awk '{print $5}')
# Filter out accounts with no blob containers.
for account in $accounts
do
char_count=$(az storage container list --account-name $account | wc -c)
if [[ $char_count -lt 4 ]];
then
echo "$account has no blobs."
else
echo "$account has blobs."
echo "$account" >> accounts_with_blobs.csv
fi
done