Skip to content

Bulk retrieval of data using the Graph module bundle #265

@KirkMunro

Description

@KirkMunro

The Get-Mg* cmdlets in this module bundle seem to handle the "retrieve all" and "retrieve 1" cases pretty well, where you can retrieve all records of a certain type (e.g. Get-MgUser with no parameters) or one record of that type (e.g. Get-MgUser -UserId $userId).

What about retrieve many?

I often need to retrieve a specific set of records, but there isn't an easy way to do that. Most Get-* cmdlets in PowerShell support this by defining the identifying parameter as an array, but in the Graph module bundle, the identifying parameters are singular, so I either need to make many Get-Mg* calls in a row, passing in one identifier at a time, or I need to use the common -Filter parameter with an "or" filter than I manually build.

The first option is undesirable because this requires multiple REST invocations to retrieve what should be a single dataset.

The second option is undesirable because I need to manually build that filter, which is sent as a query parameter to the Graph endpoint, which means I'm limited by the length of the query parameter string and the length of the uri, and I don't want to have to think about such things.

With that in mind, I'm wondering the following:

  1. Is there a better way to retrieve bulk (but not all) data than this using the Graph module bundle today?

  2. Would you consider enhancing the Graph module bundle to make this easier by (a) making identifying properties arrays so that you can look up multiple values at once, and (b) internally using those values to build the minimum required number of calls possible based on management of the query string and knowledge of the max uri string length, eliminating the complexity and knowledge that is otherwise required on the callers part, and making the data retrieval cmdlets scale optimally for automation use?

    Automatic request batching could also play into this, where the bulk request could be broken up into chunks that fit the bounds defined by the request size, and then sent out in one batch request for fast retrieval of the data in Azure, with paged results for the data coming back.

  3. What is the maximum Uri string length that is permitted for a Graph request, and how much of that is available for a query string?

AB#7412

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions