How can I add pagination as a parameter for the Azure Data Factory Rest API call to retrieve all data?

Vegnesa, Savio 0 Reputation points
2024-07-16T10:03:31.7066667+00:00

How can I add pagination(Limit and Offset ) as a parameter for the Pipelines_ListByFactory API call?

https://video2.skills-academy.com/en-us/rest/api/datafactory/pipelines/list-by-factory?view=rest-datafactory-2018-06-01&tabs=HTTP

I have 65 pipelines in my Data Factory, where as the API response only gives 50 pipelines. Is there a limit to the API response, if so and how can I retrieve all pipelines?

Currently, we are using the following APIs. Can you let us know how pagination as parameter can be applied to these APIs as well?

  • Pipelines - List By Factory
  • Datasets - List By Factory
  • Data Flows - List By Factory
  • Linked Services - List By Factory
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,519 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Amira Bedhiafi 22,541 Reputation points
    2024-07-16T21:59:05.2933333+00:00

    To add pagination parameters to the Azure Data Factory REST API calls, you'll need to use the $top and $skip query parameters. These parameters allow you to control the number of items returned and the starting point of the results.

    For the Pipelines_ListByFactory API and other similar APIs, you can use these parameters as follows:

    1. $top: Specifies the maximum number of items to return in the response.
    2. $skip: Specifies the number of items to skip before starting to return results.

    Here's how you can modify your API calls to include pagination:

    1. Pipelines - List By Factory:
    
    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelines?api-version=2018-06-01&$top=50&$skip=0
    
    
    1. Datasets - List By Factory:
    
    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/datasets?api-version=2018-06-01&$top=50&$skip=0
    
    
    1. Data Flows - List By Factory:
    
    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/dataflows?api-version=2018-06-01&$top=50&$skip=0
    
    
    1. Linked Services - List By Factory:
    
    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/linkedservices?api-version=2018-06-01&$top=50&$skip=0
    
    

    To retrieve all pipelines (or other resources) when there are more than 50, you'll need to make multiple API calls, incrementing the $skip parameter each time. Here's a pseudo-code example of how you might implement this:

    
    def get_all_pipelines(factory_name):
    
        pipelines = []
    
        skip = 0
    
        top = 50
    
        while True:
    
            url = f"https://management.azure.com/subscriptions/...&$top={top}&$skip={skip}"
    
            response = make_api_call(url)
    
            new_pipelines = response.json()['value']
    
            pipelines.extend(new_pipelines)
    
            if len(new_pipelines) < top:
    
                break  # We've retrieved all pipelines
    
            skip += top  # Prepare for the next page
    
        return pipelines
    
    

  2. Vegnesa, Savio 0 Reputation points
    2024-07-17T07:21:30.52+00:00

    Thank you for your quick response.

    However, the approach you suggested to use $top and $skip parameters does not seem to be working. I have tested multiple scenarios by changing the values of $top and $skip, but the API still returns only 50 pipelines, regardless of the values provided. I have attached a screenshot for reference.

    User's image

    Can you help me understand why the pagination parameters might not be working and suggest an alternative method to retrieve all 65 pipelines from my Data Factory?

    0 comments No comments

  3. AnnuKumari-MSFT 32,661 Reputation points Microsoft Employee
    2024-08-12T07:09:51.0833333+00:00

    Hi Vegnesa, Savio ,

    Kindly check the below blog post which covers the implementation for your scenario:

    https://datakuity.com/2022/07/01/perform-pagination-in-azure-data-factory/

    Hope it helps. Kindly let us know how it goes. Thankyou

    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.