Created
March 10, 2022 20:28
-
-
Save rybons/07f659e9a382c5cc1ac182f0ff3a1aa9 to your computer and use it in GitHub Desktop.
Azure CLI Helpers
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
az_list(){ | |
az account list --output table | |
} | |
az_sub(){ | |
if [ "$1" = "" ] | |
then | |
echo "Usage: az_sub <subscription-id>" | |
return 1 | |
fi | |
az account set --subscription="$1" | |
} | |
az_creds(){ | |
if [ "$1" = "" ] | |
then | |
echo "Usage: az_creds <role-name> <subscription-id>" | |
return 1 | |
fi | |
az ad sp create-for-rbac --role="Contributor" --name "$1" --scopes="/subscriptions/$2" | |
} | |
az_sp_login(){ | |
if [ "$1" = "" ] | |
then | |
echo "Usage: az_sp_login <client-id> <client-secret> <tenant-id>. See: https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli#sign-in-with-a-service-principal" | |
return 1 | |
fi | |
az login --service-principal -u $1 -p $2 --tenant $3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment