Create a Service Principal with Azure CLI

In this Azure CLI post, we will create an Azure Service Principal using the Azure CLI command line utility.

Azure Service Principal (SP) is like a service account that allows applications and services to log in to Azure resources.

Create a Service Principal

Before we start, ensure you have Azure CLI installed on your machine and are logged in to Azure using the following command.

az login 

To create an SP account, run the following command. Make sure you set a name, subscriptionId and resource group.

az ad sp create-for-rbac -n "spName" --role owner --scopes subscriptions/<subscriptionId>/resourceGroups/<resourceGroup>

Please note that the above command will create the SP account and give it owner permissions on the resource group level.

To list all the SP accounts in the tenant, run the following command.

az ad sp list --output table


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.