Skip to content

Instantly share code, notes, and snippets.

@pkskelly
Created December 22, 2017 01:51
Show Gist options
  • Save pkskelly/baf8edfd849e69d502265ea70d2e6cb5 to your computer and use it in GitHub Desktop.
Save pkskelly/baf8edfd849e69d502265ea70d2e6cb5 to your computer and use it in GitHub Desktop.
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