Skip to content

Instantly share code, notes, and snippets.

@GuyHarwood
Created April 2, 2024 07:48
Show Gist options
  • Save GuyHarwood/db836abb9500343ae80b45a0fc926341 to your computer and use it in GitHub Desktop.
Save GuyHarwood/db836abb9500343ae80b45a0fc926341 to your computer and use it in GitHub Desktop.
Delete multiple storage account blob containers via Azure CLI
#!/bin/bash
set -e
if [ -z "$1" ]
then
echo "storage account name required"
exit 1
fi
if [ -z "$2" ]
then
echo "blob container name prefix required"
exit 1
fi
storageAccountName=$1
containerPrefix=$2
az storage container list --auth-mode login --account-name $storageAccountName --prefix $containerPrefix --query "[].name" --output tsv | xargs -n 1 az storage container delete --account-name $storageAccountName --auth-mode login --name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment