Skip to content

Instantly share code, notes, and snippets.

@codycodes
Last active July 5, 2022 15:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codycodes/08ee7e28c59e808b918cc7554d839ff8 to your computer and use it in GitHub Desktop.
Save codycodes/08ee7e28c59e808b918cc7554d839ff8 to your computer and use it in GitHub Desktop.
Create + fetch details for Azure Service Principal using az cli (Unix/Linux)
#!/bin/bash
# install homebrew (if on Windows install the msi)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update && brew install azure-cli
# brings up UI to login to Azure
az login
# creates service principal
az ad sp create-for-rbac
# fetches the subscription ID in which the sp was created
echo "Subscription ID:"
az account list --query "[?isDefault].id" -o tsv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment