Skip to content

[Feature]: Search-AzGraph should support paging with a new -All switch #27737

Closed
@o-l-a-v

Description

@o-l-a-v

Description of the new feature

Search-AzGraph does not support paging in itself. One can specify -First to 1000, but that's not always enough.

As of today I handle paging myself like this (in case it is useful for others):

# Assets
$QueryResults = [System.Collections.Generic.List[PSCustomObject]]::new()
Remove-Variable -Name 'Response' -Force -ErrorAction 'Ignore'

## Get resource containers with Resource Graph which uses paging
do {
    $Splat = [ordered]@{
        'Query'          = [string] '<insert_query_here>
        'UseTenantScope' = [bool] $true
    }
    if (-not [string]::IsNullOrEmpty($Response.'SkipToken')) {
        $Splat.Add('SkipToken', $Response.'SkipToken')
    }
    $Response = Search-AzGraph @Splat
    $QueryResults.AddRange($Response.'Data')
    Write-Information -MessageData ('Found {0} so far.' -f $QueryResults.'Count'.ToString())
} until ([string]::IsNullOrEmpty($Response.'SkipToken'))

Proposed implementation details (optional)

Support a -All switch that handles paging and returns all results.

Activity

added
feature-requestThis issue requires a new behavior in the product in order be resolved.
needs-triageThis is a new issue that needs to be triaged to the appropriate team.
on May 12, 2025
changed the title [-][Feature]: `Search-AzGraph` should support paging with `-All` switch[/-] [+][Feature]: `Search-AzGraph` should support paging with a new `-All` switch[/+] on May 12, 2025
github-actions

github-actions commented on May 12, 2025

@github-actions

Here are some similar issues that might help you. Please check if they can solve your problem.


Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Thanks for the feedback, I'll loop in Resource Graph team.
The common practice in Azure PowerShell is to handle pagination and return all items by default (Get-AzResource for example) unless if Search-AzGraph has its reason.

Reference:

Powered by issue-sentinel

o-l-a-v

o-l-a-v commented on May 12, 2025

@o-l-a-v
Author

I'm apperently not good enough at searching for open issues. Thanks bot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @o-l-a-v

        Issue actions

          [Feature]: `Search-AzGraph` should support paging with a new `-All` switch · Issue #27737 · Azure/azure-powershell