I have a script that I want to use for Azure to return the resource group, storage account name, storage container name, name of the blob object, size of the blob object, and storage tier.
I have the following:
#!/bin/bash
resourceGroup=$1
storageAccount=$2
containers="$(az storage container list --account-name $2 --auth-mode login --query "[].[name]" -o tsv)"
for c in $containers
do
blob_info=$(az storage blob list --account-name $2 \
--auth-mode login --container-name ${c} \
--query "[].[container,name,properties.contentLength,properties.blobTier]"
-o tsv)
echo "$resourceGroup,$storageAccount,$blob_info" | tr '\t' ','
done
When there are multiple blob items in the JSON I expect the output to show the resource group and storage account along with the complete blob_info for every blob item like this:
$resourceGroup,$storageAccount,$blob_info
$resourceGroup,$storageAccount,$blob_info
However when there are 2 blob items in one JSON the output looks like this (it doesn't echo out the $resourceGroup,$storageAccount for the second blob item in that same JSON output).
$resourceGroup,$storageAccount,$blob_info
$blob_info
I'm thinking it's something simple I must be missing here.
Something like this should be more correct: