Freigeben über


[AAD] How to create Service Principal through CLI

There are multiple ways to generate the Service Principal for Azure AD. Say, through portal, CLI or PowerShell. I always used Azure portal for this registration. But started liking CLI way of generating principal which is very simple and easy to register and generate the required keys and move on. Yes, many times you would find this step as a prerequisites or in mid way to continue say Azure Data Lake Analytics query or ADAL programming.

 $ az login
 $ az account list -o table

$ az ad sp create-for-rbac --name MikkyDemoTraining --years 1output: { "appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "displayName": "MikkyDemoTraining", "name": "https://MikkyDemoTraining", "password": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" }

Ps: Take note of the password value for later references, otherwise you may need to regenerate again.

For more detail - /en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest