Azure Resource Graph Explorer - Pagination

Prateek Gupta 1 Reputation point
2022-07-19T13:52:30.89+00:00

I am trying to fetch details from Azure Resource Graph Explorer via c#. As the data to be fetched has more than 1000 entries, I am not able to fetch all data. In response I get total number to records available for the query along with skiptoken. Not able to get the way to fetch the remaining data via skiptoken. I went through microsoft documentation for the same, it also doesn't mention about how to get the rest data. Require clarification on the same. Following code was used to fetch details.222352-capture.jpg

Azure Resource Mover
Azure Resource Mover
An Azure service used for moving multiple resources between Azure regions.
232 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 21,376 Reputation points
    2022-07-24T10:41:42.577+00:00

    Hi @Anonymous ,

    Thank you for reaching out to Microsoft Q&A for this question.

    I understand that you are trying to implement pagination using SkipToken when the response has > 1000 record count. For it, please see the link about Skipping records. According to it, in the REST API, the control is $skip and is part of QueryRequestOptions.

    Thus, using the same code snippet as available in the question, you can use QueryRequestOptions with QueryRequest to include SkipToken returned as shown below:

    Console.WriteLine($"Total Records : {response.TotalRecords}");  
    Console.WriteLine($"Current read: {response.Count}");  
      
    while (response.SkipToken is not null)  
    {  
        request.Optionsrequest. OptionsuestOptions() { SkipToken = response.SkipToken };  //Include the SkipToken received with the QueryRequest  
        response = argClient.Resources(request);  
      
        Console.WriteLine($"Current read: {response.Count}");  
    }  
    

    The output from the above snippet looks as below:
    224113-image.png

    For more details, see:
    QueryRequest.Options Property
    QueryRequestOptions Class

    Please let me know if you have any questions.

    ---
    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments

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.