Skip to content

Instantly share code, notes, and snippets.

@jim-minter
Created September 5, 2018 22:45
Show Gist options
  • Save jim-minter/a108288a581c053cdf2e62f6998b6339 to your computer and use it in GitHub Desktop.
Save jim-minter/a108288a581c053cdf2e62f6998b6339 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
usage() {
cat <<EOF >&2
usage:
$0 get-config resourcegroup
EOF
exit 1
}
case "$1" in
get-config)
if [[ "$#" -ne 2 ]]; then usage; fi
OSACONFIG=$(mktemp -d)
trap "rm -rf $OSACONFIG" EXIT
export AZURE_STORAGE_ACCOUNT=$(az storage account list -g $2 | jq '.[] | select(.tags.type == "config") | .name ' | tr -d '"')
export AZURE_STORAGE_KEY=$(az storage account keys list -n $AZURE_STORAGE_ACCOUNT -g $2 --query '[0].value' | tr -d '"')
az storage blob download --file $OSACONFIG/config -c config -n config --no-progress >/dev/null
cat $OSACONFIG/config
;;
*)
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment