Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use nextLink property in azure pagination in /providers/Microsoft.Compute/virtualMachines REST API

I am calling azure /providers/Microsoft.Compute/virtualMachines REST API. I need to implement pagination for this API. As per Azure docs Use the nextLink property in the response to get the next page of virtual machines. nextLink property is The URI to fetch the next page of VMs. Call ListNext() with this URI to fetch the next page of Virtual Machines. I am not using Azure SDK for making azure REST calls. Do I need to set the authentication header for this URI? How the URI will look like?

like image 548
Maninder Chhabra Avatar asked Dec 06 '25 20:12

Maninder Chhabra


1 Answers

nextLink property is a URL that you receive if the server sends a partial response for your request.

For example, let's say you have 100 VMs in your Azure Subscription and when you try to list the VMs, the response only contains information about 50 VMs. Along with that response, you will get nextLink property using which you can fetch next 50 VMs.

It looks almost identical to your original request URL but it will have a $skiptoken query string parameter.

For example, if your original request URL looks something like:

https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines?api-version=2021-03-01

then your nextLink would look something like:

https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines?api-version=2021-03-01&$skiptoken=<somevalue>.

You would still need to add authorization header to your request.

Please note that $skiptoken is an opaque value and you should not try to infer its meaning or define any business rules on its value. If you get nextLink in the response, then it would simply mean there's more data available on the server.

like image 117
Gaurav Mantri Avatar answered Dec 08 '25 12:12

Gaurav Mantri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!