Finding Applications and Service Principals by ApplicationId
See original GitHub issueI’m using the fluent API to authenticate a service principal that has full read/write access to the directory and numerous subscriptions. Given that I only have an application id or client id, I’d like to search for the application and service principal in the directory that I use to authenticate against so I can give it access to Key Vault and other resources I’m about to create.
We never reference service principals or applications by its object id or name.
Neither the following works:
string tenantId = "example.onmicrosoft.com";
string clientId = "ead0153a-1234-1234-1234-123456789f98";
string clientSecret = "passsword";
ServicePrincipalLoginInformation information = new ServicePrincipalLoginInformation();
information.ClientId = clientId;
information.ClientSecret = clientSecret;
AzureCredentials credentials = new AzureCredentials(information, tenantId, AzureEnvironment.AzureGlobalCloud);
var authenticated = Azure.Authenticate(credentials);
var thisApplication = authenticated.ActiveDirectoryApplications.GetById(clientId);
var thisServicePrincipal = authenticated.ServicePrincipals.GetById(clientId);
Shouldn’t there be a method on both authenticated.ActiveDirectoryApplications
and authenticated.ServicePrincipals
to FindByApplicationId
?
The only workaround I have today is to List all the applications, and search for one where the app.ApplicationId
matches the clientId
. This is very inefficient and extremely slow (it takes minutes) when you have thousands of applications and service principals in the directory.
Is there another way to do this?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top GitHub Comments
In essence, the request is to support the following query using the fluent api. It takes approx. 2 seconds to complete. This is much more efficient.
Close this as
GetName
works in this case. Please feel free to reopen if any issue persist.