Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

783
Views
Does anyone know what a AsyncPageable is?

I'm trying to do a get all from an Azure service and it returns an AsyncPageable. According to the doc it says

A collection of values that may take multiple service requests to iterate over.

Does that mean that it is equal to doing the request for a single item multiple times with a loop?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If a service call returns multiple values in pages it would return Pageable<T>/AsyncPageable<T> as a result. Check out Consuming Service Methods Returning AsyncPageable.

To get more clarity, have a look at below: This shows control over receiving pages of values from the service use AsyncPageable<T>.AsPages method:

// call a service method, which returns AsyncPageable<T>
AsyncPageable<SecretProperties> response = client.GetPropertiesOfSecretsAsync();

await foreach (Page<SecretProperties> page in response.AsPages())
{
    // enumerate through page items
    foreach (SecretProperties secretProperties in page.Values)
    {
        Console.WriteLine(secretProperties.Name);
    }

    // get continuation token that can be used in AsPages call to resume enumeration
    Console.WriteLine(page.ContinuationToken);
}

If your project doesn't have C# 8.0 enabled you can still iterate over AsyncPageable using a while loop:

// call a service method, which returns AsyncPageable<T>
AsyncPageable<SecretProperties> response = client.GetPropertiesOfSecretsAsync();

IAsyncEnumerator<SecretProperties> enumerator = response.GetAsyncEnumerator();
try
{
    while (await enumerator.MoveNextAsync())
    {
        SecretProperties secretProperties = enumerator.Current;
        Console.WriteLine(secretProperties.Name);
    }
}
finally
{
    await enumerator.DisposeAsync();
}

Check out Azure.Core Response samples to understand more about this.

To change page size, you can use pageSizeHint parameter to AsPages method.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!