Skip to content
CogniSkill

LESSON 3 OF 4

Exercise: a failed middle page

Practice notesBooks for further learning

Change the evidence

Separate live permissions

For a possible users report, locate the endpoint’s current permissions and supported properties in official documentation. Distinguish delegated access, where a signed-in user’s context is involved, from application access. Do not guess a broader scope to make a failed request succeed.

Plan rate-limit handling

A 429 is not an empty page. A live collector should honour the service’s retry guidance, bound the retries, and mark a run failed when the retry budget is exhausted. Retrying every error identically may repeat authorization failures indefinitely.

Specify the report boundary

Add a collected-at timestamp, record count, page count, requested properties and completeness flag. A reviewer should be able to see whether the result came from a complete collection rather than infer completeness from a polished CSV.

Diagnose failures

The report always contains the first hundred records

Check whether the collector follows next-links rather than assuming one response is complete. A service page limit is not the size of the tenant.

The collector gets forbidden and returns no users

Authorization failure is not an empty directory. Preserve the error and review endpoint permission, token context and consent.

Retrying creates an infinite run

Use bounded retries and a page-loop guard. The recovery rule must terminate and report failure when it cannot satisfy the collection contract.

A second worked example

# Local sample: no connection required
$users = @([pscustomobject]@{
 DisplayName='Ana Example'; UserPrincipalName='ana@example.test'
})
$users | Select-Object DisplayName, UserPrincipalName
# Optional live pattern: after approved SDK install and permission review
# Connect-MgGraph -Scopes 'User.ReadBasic.All'
# Get-MgUser -All -Property DisplayName,UserPrincipalName |
#   Select-Object DisplayName,UserPrincipalName
# Disconnect-MgGraph

The local section proves projection of sample properties, not live permissions. The commented pattern shows the relationship between sign-in, retrieval and output. Verify current consent and endpoint requirements before running it in an authorized tenant. -All requests all pages supported by that cmdlet; selecting fields also limits what you retain in the report.

Transfer exercise

A report has exactly one page of users. What evidence should you inspect before concluding that this is the entire directory?

Worked transfer answer

Inspect paging behavior, applied filters, permission scope and any errors. Compare the intended population with an approved independent count. A successful first page is not proof of completeness. Never log access tokens to debug the mismatch.

Exercise: a failed middle page

The first page contains 100 users and the second request receives a throttling response with a Retry-After value. The report deadline is sooner than the required wait. What should the collector publish?

Worked reasoning

It must not label the first page a complete inventory. Respect supported retry guidance within the job budget or stop/defer with a partial/incomplete status and clear provenance. Retrying faster because the deadline is inconvenient can worsen throttling. A downstream absence report should refuse incomplete collection rather than classify every missing user as deleted.

Worked laboratory solution

Compare your reasoning with the worked solution

The successful sequence collects U1,U2, waits/retries according to the mocked throttling contract and bounded policy, collects U3,U4, then U5, and marks complete only after the terminal page. Expected unique users are five. The intermediate count of two is partial, not an authoritative total. Do not treat every error as retryable: an authorization failure needs permission/context diagnosis. If retries exhaust, retain collected data with an explicit incomplete/error status rather than quietly publishing it as complete.

Official reference for further study

Download the course workbook and practice materials

COGNISKILL BOOKS

Go deeper with a related book

This short course practises a focused skill. Related CogniSkill books offer an optional longer learning and preparation path; this course does not claim full exam coverage.

Sign in to save lesson completion. Reading position is separate from completion.

Practice notes — your working space

Save predictions, outputs and explanations as you work. Notes stay on this browser, not your account; people sharing this browser can access them. Avoid passwords and sensitive data. Export to keep a portable copy, or clear your notes before leaving a shared device.

How was this lesson?

Help us improve this lesson.