Skip to content

Instantly share code, notes, and snippets.

@jmassardo
Created December 12, 2018 14:19
Show Gist options
  • Save jmassardo/21e4f72c994449e5b0874674fd3164f0 to your computer and use it in GitHub Desktop.
Save jmassardo/21e4f72c994449e5b0874674fd3164f0 to your computer and use it in GitHub Desktop.
Commands for creating an Azure Service Principal for Test Kitchen, Packer, Terraform, etc.
# Get a list of all the available subscriptions
az account list
# Output
#
#[
# {
# "cloudName": "AzureCloud",
# "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" <- Subscription ID
# "isDefault": true,
# "name": "My Awesome Azure Subscription",
# "state": "Enabled",
# "tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
# "user": {
# "cloudShellID": true,
# "name": "name@domain.tld",
# "type": "user"
# }
# }
#]
# Create a Service Principal using the desired subscription id from the command above
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#Output
#
#{
# "appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", <- Also known as the Client ID
# "displayName": "azure-cli-2018-12-12-14-15-39",
# "name": "http://azure-cli-2018-12-12-14-15-39",
# "password": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
# "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment