Create a gist now

Instantly share code, notes, and snippets.

@kwart /azure
Created Jul 1, 2016

What would you like to do?
Azure CLI by using Docker image microsoft/azure-cli (credentials and configuration are stored in extra docker volume)
#!/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