azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

`az ad group member list` does not list service principals

Open kevinharing opened this issue 4 years ago • 29 comments

Related command az ad group member list

Describe the bug az ad group member list does not list service principals.

To Reproduce Run az ad group member list --group <group_name> on a group with members of type Service Principal.

Expected behavior Returns all members of the group, including Service Principals.

Additional context

{
  "azure-cli": "2.37.0",
  "azure-cli-core": "2.37.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "account": "0.2.1",
    "aks-preview": "0.5.10",
    "application-insights": "0.1.13",
    "datafactory": "0.5.0"
  }
}

kevinharing avatar May 30 '22 09:05 kevinharing

@jiasli for awareness

yonzhan avatar May 30 '22 09:05 yonzhan

Please also see https://github.com/Azure/azure-cli/issues/16123#issuecomment-1060321911

According to List members API's documentation:

https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0&tabs=http

Currently service principals are not listed as group members due to staged roll-out of service principals on Graph V1.0 endpoint.

This is a feature gap between AD Graph and Microsoft Graph.

As a workaround, you may use az rest to call beta API: https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-beta&tabs=http

jiasli avatar May 30 '22 12:05 jiasli

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost avatar Jul 22 '22 14:07 ghost

bump

We've discovered that if we log into azure cloud shell (azure-cli v2.48.1) as the service principal behind our Azure DevOps service connection, we can't use az cli to add, list, or check group members of a security group, even though our service principal owns the group. (Yields Insufficient privileges to complete the operation.)

We've also discovered that if we add a managed identity to said group manually, the managed identity isn't listed as a group member by az ad group list --group '...' (no matter who you run as)

#!/bin/bash
# running as the service principal behind an ADO service connection
principal="xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # where $principal is a system managed identity from a linux web app
group="yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy" # where $group is an AAD security group with nobody in it owned by a service principal

echo "##[command]az ad group member check --group \"$group\" --member-id \"$principal\""
is_member=$(az ad group member check --group "$group" --member-id "$principal" | jq -r '.value')
if [ "$is_member" = "false" ]; then
    echo "##[command]az ad group member add --group \"$group\" --member-id \"$principal\""
    az ad group member add --group "$group" --member-id "$principal"
else
    echo "##[warning]principal \"$principal\" is already a member of group \"$group\""
fi

echo "##[command]az ad group member list --group \"$group\""
az ad group member list --group "$group"

ncook-hxgn avatar Jun 29 '23 16:06 ncook-hxgn

Is there a plan to fix this issue?

Currently I'm using:

GROUP_ID="GROUP_UUID"
az rest \
  --method get \
  --url https://graph.microsoft.com/beta/groups/$GROUP_ID/members |\
   jq '.value[] | select(.["@odata.type"] == "#microsoft.graph.servicePrincipal") | .id'

Shaked avatar Dec 10 '23 23:12 Shaked

Could this be reopened @jiasli ? Thank you

FlorentATo avatar Jan 10 '24 22:01 FlorentATo

Another google search that brings me to a posting of yet another quietly broken part of the API that requires using the beta duct tape endpoint workaround. Same issue for retrieving last login times. There are many examples of such cases that have been open for years. When they charge $6 per user per month, something seems very wrong here. I loathe this API and the surprise breakages that occur every few months.

valberico avatar Nov 19 '24 16:11 valberico

Hi @jiasli, can this be reopened please?

murphm54 avatar Feb 24 '25 11:02 murphm54

I am facing the same issue

milosbithawk avatar Mar 10 '25 11:03 milosbithawk

Can't believe such a basic check on a group membership for ANY type of member, is not possible...

DjangoLohn avatar May 01 '25 12:05 DjangoLohn

I can't believe it too. I just faced the same issue, Google led me here. More than 3 years and no action from Microsoft...

Jarod-Felson avatar Dec 12 '25 13:12 Jarod-Felson

Wow, this is incredible. Almost 4 years now and still facing this issue. Absolutely mental for such a basic action...! 🤣

Sebastian-Negoescu avatar Feb 13 '26 10:02 Sebastian-Negoescu

jiasli reopened this 2 days ago

THERE IS HOPE FOLKS, HAVE FAITH! :D

FlorentATo avatar Feb 15 '26 03:02 FlorentATo

This is a joke, right?!? What a dumpsterfire...

GY-blangers avatar Feb 17 '26 11:02 GY-blangers

I know this is not a solution but many people will find this page so just sharing a workaround to use: az rest --uri https://graph.microsoft.com/beta/groups/[GROUPID]/members | jq .value[].displayName az rest --uri https://graph.microsoft.com/beta/groups/a123b4cd-efg5-678h-9ijk-7392b165e6d5/members | jq .value[].displayName

m3ngi3 avatar Feb 24 '26 10:02 m3ngi3

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

please don't close it, it seems like a fairly reasonable request

ncook-hxgn avatar Mar 03 '26 13:03 ncook-hxgn

I hate "+1" and "bump" messages like the next guy, but this ^ type of automation pushes users to create unnecessary noise just to keep issues opened.

FlorentATo avatar Mar 10 '26 19:03 FlorentATo

Feels like the goal is to auto close the ticket and never fix the graphiapi. Azure/entra has a captive user base. What are they going to do, switch to something else over the lack of robust features?Sent from my iPhoneOn Mar 10, 2026, at 14:52, Florent Tatard @.***> wrote:FlorentATo left a comment (Azure/azure-cli#22664) I hate "+1" and "bump" messages like the next guy, but this ^ type of automation pushes users to create unnecessary noise just to keep issues opened.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

valberico avatar Mar 10 '26 20:03 valberico

I guess ms wants me to hear from myself. Is anyone working this bug? Why are you trying to close it every week?Sent from my iPadOn Mar 17, 2026, at 16:26, microsoft-github-policy-service[bot] @.***> wrote:microsoft-github-policy-service[bot] left a comment (Azure/azure-cli#22664) Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

valberico avatar Mar 17 '26 21:03 valberico

I guess it's easier to "act" like nothing happens and close this, instead of actually working on it, from Microsoft's/the Assignee's perspective. The time that's passed so far and the attitude towards the resolution of this issue, even with all of the people trying to raise the awareness on this thread, sincerely tells us that there is no desire at all to fix it. What a shame of an attitude, of a product quality and an overall experience towards such a small ask.

Sebastian-Negoescu avatar Mar 18 '26 09:03 Sebastian-Negoescu