@Joel Pangilinan Thank you for reaching out to us.
To list all file shares and blobs for all storage accounts on all subscriptions, you can use the script below. You might need to modify any of them to suite your need.
To use bash script and one-liner using azure-cli 2.0.79 that might help you get started with iterating over all storage accounts under a single subscription. You can update your Azure-cli if there is a need.
From a bash script:
#!/bin/bash
#get a list of storage accounts
for account in `az storage account list --query '[].{Name:name}' --output tsv`
#iterate over storage accounts
do
echo $account $(az storage share list --account-name $account --output tsv | awk '{print $2}')
done
One liner:
for account in `az storage account list --query '[].{Name:name}' --output tsv`;
do echo $account $(az storage share list --account-name $account --output tsv | awk '{print $2}') ;
done
This should be similar to the output:
storageaccountname1 <share1> <share2> <share3>
storageaccountname2 <share1> <share2>
Also, to get the Azure File Share through PowerShell, you'd better use the Azure PowerShell instead of the Azure CLI, I think the CLI is not suitable for Linux. You can install the Azure PowerShell module and then use the script like this:
#Get storageaccount names
$storageAccount = Get-AzStorageAccount
#Now iterate over the storageaccounts
foreach ($storage in $storageAccount) {
if($storage.PrimaryEndpoints.File -ne $null){
Get-AzRmStorageShare -ResourceGroupName $storage.ResourceGroupName
}
}
Hope this helps! Kindly let us know if the above helpful and solve the issue.
Cheers.
Sina