Created
July 3, 2018 09:36
-
-
Save hitenpratap/a9e672b624604b47cfe0fb5ac660e226 to your computer and use it in GitHub Desktop.
Download Latest Blob from a container using Azure CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Downloading latest Database dump from Sandbox Server" | |
AZURE_STORAGE_CONNECTION_STRING="" | |
AZURE_CONTAINER_NAME="" | |
AZURE_DB_ZIP_FILE_NAME=$(az storage blob list --connection-string "$AZURE_STORAGE_CONNECTION_STRING" --container-name "$AZURE_CONTAINER_NAME" --query "reverse(sort_by([], &properties.lastModified)[*].{name: name, lastModified: properties.lastModified})[:1]" --prefix "sandbox" | jq '.[0] | {name}.name') | |
AZURE_DB_ZIP_FILE_NAME=${AZURE_DB_ZIP_FILE_NAME//\"/} | |
echo $AZURE_DB_ZIP_FILE_NAME | |
rm -rf /mnt/tempSandboxData/* | |
echo "Dowloading latest sandbox db dump named ===>>> $AZURE_DB_ZIP_FILE_NAME" | |
az storage blob download --connection-string "$AZURE_STORAGE_CONNECTION_STRING" --file "/mnt/tempSandboxData/latest-sandbox-db-dump.zip" --name "$AZURE_DB_ZIP_FILE_NAME" --container-name "$AZURE_CONTAINER_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment