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