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

`az ad sp list` should by default show the first few pages, rather just hang to get all of them

Open SteveLasker opened this issue 10 years ago • 29 comments

Kinda says it all

SteveLasker avatar Oct 25 '16 06:10 SteveLasker

are you using your microsoft.com account? If yes, then this hangs might be just long-delay. Not saying this is ideal, but there are 100k+ users account to retrieve. There are server side filters you can use to narrow down the data.

yugangw-msft avatar Oct 25 '16 16:10 yugangw-msft

The cli need to support streaming (start to display before all data are pulled down), rather wait for thousands of get operations returned.

yugangw-msft avatar Oct 25 '16 16:10 yugangw-msft

I was wondering if az ad sp list can have an option (or by default) to show MY service principals rather than ALL service principals. For applications, the portal has an option to show All apps or My apps. It doesn't make sense to me if by default it returns all service principals.

djyou avatar Oct 27 '16 21:10 djyou

@yugangw-msft : List vs list-all?

mayurid avatar Oct 31 '16 23:10 mayurid

It winds down to whether there is ownership such information inside the graph application object. AFAIK, there are not. The following is the object dump

{
      "odata.type": "Microsoft.DirectoryServices.Application",
      "objectType": "Application",
      "objectId": "005b1e87-7383-4f8c-9a84-a913f9137a49",
      "deletionTimestamp": null,
      "appId": "0675995d-e1dc-4943-beb6-4df25e02c6d5",
      "appRoles": [],
      "availableToOtherTenants": false,
      "displayName": "updated Saml display name",
      "errorUrl": null,
      "groupMembershipClaims": null,
      "homepage": null,
      "identifierUris": [
        "http://samlCustom",
        "http://customappsso/d18d09a13dd340fa8b6a1733bad042e1/"
      ],
      "keyCredentials": [],
      "knownClientApplications": [],
      "logoutUrl": null,
      "oauth2AllowImplicitFlow": false,
      "oauth2AllowUrlPathMatching": false,
      "oauth2Permissions": [
        {
          "adminConsentDescription": "Allow the application to access SAML Custom App #2 on behalf of the signed-in user.",
          "adminConsentDisplayName": "Access SAML Custom App #2",
          "id": "5279cafd-2efd-4067-9a05-2e4d529876c0",
          "isEnabled": true,
          "type": "User",
          "userConsentDescription": "Allow the application to access SAML Custom App #2 on your behalf.",
          "userConsentDisplayName": "Access SAML Custom App #2",
          "value": "user_impersonation"
        }
      ],
      "oauth2RequirePostResponse": false,
      "passwordCredentials": [],
      "publicClient": null,
      "replyUrls": [
        "https://samlCustom"
      ],
      "requiredResourceAccess": [
        {
          "resourceAppId": "00000002-0000-0000-c000-000000000000",
          "resourceAccess": [
            {
              "id": "5778995a-e1bf-45b8-affa-663a9f3f4d04",
              "type": "Role"
            }
          ]
        }
      ],
      "samlMetadataUrl": null
    }

yugangw-msft avatar Nov 01 '16 00:11 yugangw-msft

image The portal does have a way to show My apps or All apps with two different calls in Azure Active Directory extension.

djyou avatar Nov 08 '16 19:11 djyou

@djyou Again, could you please share the object dump, which you can get by downloading the manifest from portal, or just use graph explorer. Only if there is a property in the graph, then we can filter; otherwise it is a portal specific UI profile setting which can't be used by cli command.

yugangw-msft avatar Nov 08 '16 21:11 yugangw-msft

I agreed that the manifest doesn't have user information. It was just interesting to see the portal can actually do My apps vs All apps. I am not too familiar with Graph API just curious how they did it.

djyou avatar Nov 08 '16 21:11 djyou

@djyou, you will have to ask portal team. To me it is a very UI related. First I have to make sure the combo has 'my apps' selected, otherwise the new application will be created under 'all apps', even though it was me who created. Also all applications I created in classic portal belong to "all apps" which doesn't make too much sense

yugangw-msft avatar Nov 08 '16 21:11 yugangw-msft

I logged #3323 for the original perf issue. Closing this one as it was re-topic'd

yugangw-msft avatar May 11 '17 17:05 yugangw-msft

I don't find this resolution acceptable. Streaming isn't going to help. We need to do what the portal does and by default show just my sps.

johngossman avatar Oct 16 '17 20:10 johngossman

Actually, it appears portal shows the first page, which is still better than CLI just hanging there. Suggest CLI should align to that behavior, and also outputs a warning to tell people

  1. There are more
  2. Suggest supplying arguments to accelerate the command through --spn, --display-name, etc...

yugangw-msft avatar Oct 16 '17 20:10 yugangw-msft

@yugangw-msft the problem with the suggestion of 2, is that you'd NEVER use list if you really knew what you were looking for. You'd just use show. By definition, list must return. I'm with john here; we need to return my SPs by default.

squillace avatar Oct 16 '17 20:10 squillace

+1 ... in fact, I'd also suggest that the portal default to "My apps"

johngossman avatar Oct 16 '17 20:10 johngossman

CLI probably should also expose a new flag --my-apps or --all, depending on what the default should be.

yugangw-msft avatar Oct 16 '17 20:10 yugangw-msft

That would be a fine resolution, but the default should be my apps, where you specifically request the firehose with --all if you want it, but risk it never returning (until there's paging)....

squillace avatar Oct 16 '17 20:10 squillace

What are the chances we can get this popped off the backlog? As working with RBAC service principals becomes more and more common in various services (AKS and ACR, for example), it's becoming critical that we and our customers can effectively manage our SPs.

Such management includes deletion of stale principals, but without a built-in facility for listing only the service principals associated with my subscription, I've no clear path to delete them quickly and easily (such as via script).

mmacy avatar Jan 24 '18 20:01 mmacy

cc/ @yugangw-msft @mayurid

tjprescott avatar Jan 24 '18 21:01 tjprescott

2 things

  1. Paging support from CLI
  2. GraphRBAC should be updated to support https://graph.windows.net/{tenantId}/me/ownedObjects so CLI can create and list users' own SPs

The 2nd item is SDK work. I have asked last month, but AAD GRAPH is not in the priority. Guess I will have to find cycles, and do it myself

yugangw-msft avatar Jan 24 '18 21:01 yugangw-msft

OMG. @yugangw-msft ping me and let me know who to discuss this with. :-) This is a very high priority for some. :-)

squillace avatar Jan 24 '18 21:01 squillace