Blog Post

Azure Integration Services Blog
2 MIN READ

Logic App Http pagination deeper look, build custom paging wrapper without loop

Mohammed_Barqawi's avatar
Nov 04, 2021

Introduction 

In this article I will talk how the Http action is doing the pagination on the json response.

there is some requirement to the http end point to be considered as valid pagination 

the response needs to be json

the response needs to have array named value and attribute named nextLink

Like the below diagram

The http action will check if the nextLink is exist and then make Get request to it 

It will stopped when there is no nextLink attribute in the response 

 

Note

The http method for the nextLink  will be always Get regardless of the http action.

 

Building the Wrapper for ResourceGraph Rest 

The problem 

You want to call https://management.azure.com/providers/Microsoft.ResourceGraph/resources

As in the documentation Resources - Resources - REST API (Azure Azure Resource Graph) | Microsoft Docs

 

It has unique way to handle paging, first the json structure is not as recommended by the standard http pagination also there is something called $skipToken that also need to be passed in the next call.

 

The solution

I have built wrapper logic app that will action as proxy and convert the ResourceGraph response to paging enabled response 

 

In your business logic app instead of calling the ResourceGraph Endpoint you will call the wrapper logic app 

 

 

By adopting the wrapper concept, you will avoid implementing the until loop pattern since you will utilize the built-in pagination inside the Http action  

 

How the wrapper is working 




 

 



 



1

Initialize the next Link variable by getting the value from triggerOutputs()['queries']?['nextLink']

Because it will come in the query string 

2

Initialize the request body option

This variable either has the Skiptoken or empty 

Sample value when it is not empty 

  "options": {

 "$skipToken" :"abc="   

  },


 

 

 

3

Creat the Http request that conset of the option (if it exist ) and the query 

4

Sent the request to the http end poit for the ResourceGraph 

 

 

5

Map the response to the standard pagination format 

And add the next Link attribute in case this is not the last request 


Note that I have a variable that hold the wrapper logic app url so I can build the next link 

 

 

How to use the solution 


Click on the button below to deploy the Logic app to your subscription  

 

Sample logic app templates in GitHub

Deploy to Azure: 

 

 

Cange the parameters

URL and Query

Updated Nov 04, 2021
Version 1.0
  • Mohammed_Barqawi This is a wonderful article! I tried this at my end when working on a customer's case and it works great. Thank you for this solution! 🙂

  • shaissameer's avatar
    shaissameer
    Copper Contributor

    Mohammed_Barqawi , This needs to be advertsied more :smile:. This is an amazing piece of work you have put together. The pagination issue had me hit the wall for getting a report out with more than 1000 rows. Thank you for your support. This deserves a thumbsup.

  • Francesco_beqom's avatar
    Francesco_beqom
    Copper Contributor

    While the article is good, given the fact that Logic App is a Microsoft product, I would expect more compatibility to other Microsoft product. 
    In my example Graphic Explorer run form the Portal returns all data but when you query it form Logic App asks for pagination. 

  • Ajaz_Ahamed's avatar
    Ajaz_Ahamed
    Copper Contributor

    This is a great app, I am hitting the wall due to pagination, Can someone give more details with an example here