Reputation: 106
Powershell command 'az role assignment list --assignee [email protected] --all' is giving result in powershell but no results for below code snippet.
TokenCredential azureCliCredential = new AzureCliCredentialBuilder().build();
GraphServiceClient<Request> graphClient = GraphServiceClient.builder().authenticationProvider(new TokenCredentialAuthProvider(azureCliCredential)).buildClient();
AppRoleAssignmentCollectionPage appRoleAssignments = graphClient.users("objectid of [email protected]").appRoleAssignments().buildRequest().get();
System.out.println(appRoleAssignments);
Upvotes: 0
Views: 119
Reputation: 136196
The reason it is not working is because the two things you are trying are for different things all together.
'az role assignment list --assignee [email protected] --all'
is to get Azure RBAC role assignments i.e. roles assigned to a user for managing Azure Subscriptions.
However AppRoleAssignmentCollectionPage appRoleAssignments = graphClient.users("objectid of [email protected]").appRoleAssignments().buildRequest().get();
gets the roles assigned to the user for an application in Azure AD.
To get Azure RBAC role assignments using code, your will need to use Azure SDK for Java
Upvotes: 2