Skip to content

Instantly share code, notes, and snippets.

@codycodes
Last active July 5, 2022 15:26
Show Gist options
  • 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