Skip to content

aad sp add

Adds a service principal to a registered Azure AD app

Usage

m365 aad sp add [options]

Options

--appId [appId]
ID of the application to which the service principal should be added
--appName [appName]
Display name of the application to which the service principal should be added
--objectId [objectId]
ObjectId of the application to which the service principal should be added
-h, --help
output usage information
--query [query]
JMESPath query string. See http://jmespath.org/ for more information and examples
-o, --output [output]
Output type. json,text. Default text
--verbose
Runs command with verbose logging
--debug
Runs command with debug logging

Remarks

Specify either the appId, appName or objectId. If you specify more than one option value, the command will fail with an error.

If you register an application in the portal, an application object as well as a service principal object are automatically created in your home tenant. If you register an application using CLI for Microsoft 365 or the Microsoft Graph, you'll need to create the service principal separately. To register/create an application using the CLI for Microsoft 365, use the m365 aad app add command.

Examples

Adds a service principal to a registered Azure AD app with appId b2307a39-e878-458b-bc90-03bc578531d6.

m365 aad sp add --appId b2307a39-e878-458b-bc90-03bc578531d6

Adds a service principal to a registered Azure AD app with appName Microsoft Graph.

m365 aad sp add --appName "Microsoft Graph"

Adds a service principal to a registered Azure AD app with objectId b2307a39-e878-458b-bc90-03bc578531d6.

m365 aad sp add --objectId b2307a39-e878-458b-bc90-03bc578531d6

More information