Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
azure cli commands to create a service principal
# az ad sp create-for-rbac --name "$(Service-Principal-Name)" --role "Contributor" --scope "/subscriptions/$(SubscriptionNumber)"
az ad sp create-for-rbac --name "Terraform-User-March-2021" --role "Contributor" --scope "/subscriptions/$(SubscriptionID)"
# I am replacing the tenant and subscription value with variable for security reasons
# Output from the commandline console:
Changing "Terraform-User-March-2021" to a valid URI of "http://Terraform-User-March-2021", which is the required format used for service principal names
Creating 'Contributor' role assignment under scope '/subscriptions/$(SubscriptionID)'
The output includes credentials that you must protect. Be sure that you do not include these credentials in your code or check the credentials into your source control. For more information, see
"appId": "3a08aff0-9708-455b-855c-1747fcf7434d",
"displayName": "Terraform-User-March-2021",
"name": "http://Terraform-User-March-2021",
"password": "OJ-6-uMZt4a1v~ZjLl3EdzogUnkzn9GZga",
"tenant": "$(SubscriptionTenantID)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment