Microsoft Graph not returning Service Principals inside group

Ivan Ferro 20 Reputation points
2023-11-02T11:28:14.83+00:00

I have a security group in Azure Entra ID that contains 6 service principals and a user (I added that user just for testing purposes).

I want to get the names of the Service Principals from an Azure Functions app by making a call to the "Groups[<id>].Members" Microsoft Graph endpoint. However, I am only able to get the user which is not the result I want.

My call is the following:

User's image

I tried using QueryParameters.Expands = new string[] { "members" } as stated in the docs but it doesn't work. It returns an error "Could not find a property named 'members' on type 'microsoft.graph.directoryObject'".

List group members

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,023 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 42,026 Reputation points
    2023-11-03T07:53:23.7433333+00:00

    Hi @Ivan Ferro

    The blue area of the documentation has an important note on this.

    User's image

    So try using this API on the beta endpoint or use the /groups/{id}?$expand=members API instead.

    var result = await graphClient.Groups["{group-id}"].GetAsync((requestConfiguration) =>
    {
    	requestConfiguration.QueryParameters.Expand = new string []{ "members" };
    });
    

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.