Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Azure CLI script to remove Blob storage containers serving Angular static files.
#!/bin/bash
AZURE_STORAGE_ACCOUNT=""
AZURE_STORAGE_ACCESS_KEY=""
while getopts "a:k:" opt; do
case $opt in
a)
AZURE_STORAGE_ACCOUNT="${OPTARG}"
;;
k)
AZURE_STORAGE_ACCESS_KEY="${OPTARG}"
;;
\?)
exit 1
;;
esac
done
if [[ ! $AZURE_STORAGE_ACCOUNT ]] || [[ ! $AZURE_STORAGE_ACCESS_KEY ]]; then
echo "Missing command line options. "
echo " Example: $0 -a [storage_account] -k [access key]!" >&2; exit 1;
fi
# Container names and build output locations
root_container="\$root"
assets_container="assets"
build_root_dir="${HOME}/repos/scratch/StatTracker/dist"
build_assets_dir="$build_root_dir/$APP_ASSETS"
# Show the Azure Subscription which is active
az account show
echo "Storage Account: $AZURE_STORAGE_ACCOUNT"
echo "Account Key : $AZURE_STORAGE_ACCESS_KEY"
# Delete the existing $root and assets containers
echo "Deleting the $root_container container..."
az storage container delete --name "$root_container" --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --verbose
echo "Deleting the $assets_container container..."
az storage container delete --name "$assets_container" --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --verbose
echo "Completed deleting $root_container and $assets_container containers."
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.