Created
July 1, 2016 06:22
-
-
Save kwart/ffd6dc34bb8d5e297bc34ce10764bfe6 to your computer and use it in GitHub Desktop.
Azure CLI by using Docker image microsoft/azure-cli (credentials and configuration are stored in extra docker volume)
This file contains 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/sh | |
AZURE_VOLUME=azure-config-volume | |
# before using this create a Data container for the credentials: | |
if ! $(docker volume ls -q | grep -q $AZURE_VOLUME); then | |
echo | |
echo "Azure configuration doesn't exist!!!" | |
echo | |
echo "Creating docker volume to store the configuration" | |
docker volume create --name $AZURE_VOLUME | |
echo | |
echo "Volume was created. You can continue with:" | |
echo " azure login" | |
echo " azure config mode asm" | |
echo | |
exit 2 | |
fi | |
ENV_FILE_ARG= | |
if [ -f "${HOME}/.azure/env" ]; then | |
ENV_FILE_ARG="--env-file=${HOME}/.azure/env" | |
fi | |
docker run -it --rm $ENV_FILE_ARG \ | |
-v $AZURE_VOLUME:/root/.azure \ | |
-v $HOME:$HOME \ | |
-v $PWD:/root/workdir \ | |
--net host \ | |
-w /root/workdir \ | |
microsoft/azure-cli azure "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment