How can handle pagination in Azure Rest API for hybird VM

Akash Sharma 0 Reputation points
2024-12-13T08:36:29.9966667+00:00

Scenario:
I want to handle pagination for the Azure REST API, which may return 1000 records per page by default. I need to retrieve data for a specified page. For instance, I want to get 500 records per page. So, if there are 5000 records, that would be 10 pages in total. Now, if I want to retrieve data from page number 5, it should return 500 records. How can I achieve this?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,690 questions
Azure Resource Mover
Azure Resource Mover
An Azure service used for moving multiple resources between Azure regions.
248 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 44,196 Reputation points
    2024-12-13T09:26:44.79+00:00

    Hi @Akash Sharma

    If you are using the MS Graph API, this document should be helpful to you.

    https://learn.microsoft.com/en-us/graph/paging?tabs=http.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments

  2. Akash Sharma 0 Reputation points
    2024-12-13T09:49:07.81+00:00

    Hi CarlZhao-MSFT,

    I have read document but $skip is not working for azure hybird rest api
    Is there example that can help to understand.
    https://learn.microsoft.com/en-us/rest/api/hybridcompute/machines/list-by-subscription?view=rest-hybridcompute-2024-07-10&tabs=HTTP#code-try-0


  3. Akash Sharma 0 Reputation points
    2024-12-13T09:54:37.3433333+00:00

    I have read this document but skip is not working for azure rest api for hybird compute
    https://learn.microsoft.com/en-us/rest/api/hybridcompute/machines/list-by-subscription?view=rest-hybridcompute-2024-07-10&tabs=HTTP#code-try-0

    Is there any exaple to handle pagination?

    0 comments No comments

  4. CarlZhao-MSFT 44,196 Reputation points
    2024-12-19T09:15:24.65+00:00

    Hi @Akash Sharma

    If '$top' and '$skip' are not applicable to the Azure Hybrid REST API, then this API might not support manual pagination. You can only rely on nextLink to handle pagination until all pages are fetched.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    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.