Description
When I use the aad app add command, I get the error the Service principal not found, even though the api name is correct. When I looked at the code it seems that the reason is this line
|
const servicePrincipal = this.items.find(sp => sp.servicePrincipalNames.indexOf(servicePrincipalName) > -1); |
For example when I try to register a new application with API access to Dynamics, it gives this error.

But when I look at the detail for this service principal, this service principal name ends with a slash.

When I use "00000007-0000-0000-c000-000000000000/*.crm.dynamics.com" the application registers correctly.
Steps to reproduce
Try to register a new application with this command
m365 aad app add --name "My AAD app" --withSecret --apisDelegated "https://admin.services.crm.dynamics.com/user_impersonation" --redirectUris "https://global.consent.azure-apim.net/redirect" --platform web
Expected result
The application should be registered with Dynamics CRM permission

Actual result
Error: Service principal https://admin.services.crm.dynamics.com not found
Environment
Windows 10, Powershell 7, 3.5.0
Description
When I use the aad app add command, I get the error the Service principal not found, even though the api name is correct. When I looked at the code it seems that the reason is this line
cli-microsoft365/src/m365/aad/commands/app/app-add.ts
Line 247 in c3a619d
For example when I try to register a new application with API access to Dynamics, it gives this error.
But when I look at the detail for this service principal, this service principal name ends with a slash.
When I use "00000007-0000-0000-c000-000000000000/*.crm.dynamics.com" the application registers correctly.
Steps to reproduce
Try to register a new application with this command
Expected result
The application should be registered with Dynamics CRM permission

Actual result
Error: Service principal https://admin.services.crm.dynamics.com not found
Environment
Windows 10, Powershell 7, 3.5.0