Domain 1 β€” Module 14 of 15 93%
14 of 31 overall
Domain 1: Design and develop database solutions Free ⏱ ~18 min read

Change Feed Pull Mode and Container Copy Jobs

Choose processor or pull consumption, preserve checkpoints safely, and monitor and complete a supported container copy job.

A conveyor belt with a saved position

The change feed is a record of changes your application can consume. A checkpoint says how far a consumer has safely progressed. It is not proof that an external email, payment or indexing operation happened exactly once.

Choose a consumption model according to who should manage that saved position and distribute the work.

DecisionChange Feed ProcessorPull model
Work distributionInstances coordinate through leasesApplication manages its own scheduling
ProgressProcessor checkpoints in a lease containerApplication persists continuation state
Typical fitA continuously running consumer groupExplicit page-by-page consumption and custom control
Failure designIdempotent delegate and safe retry/recoveryIdempotent page processing and safe token persistence

Do not confuse modes with consumers

Latest-version mode reports creates and updates but does not supply a complete historical audit of every intermediate version or hard delete.

All versions and deletes supports lifecycle events including intermediate versions and deletes, with its documented continuous-backup prerequisite and retention constraints. Verify current SDK and consumer support rather than assuming every change-feed integration can consume every mode.

Neither mode means your downstream side effects are exactly once. A crash after processing but before checkpointing can cause redelivery.

Leases and independent consumers

A processor uses its lease container to coordinate ownership and persist progress. Instances intended to share work must use compatible processor identity and lease configuration. Independent downstream consumers need their own progress identity; otherwise one consumer may advance the position another still needs.

Do not delete the lease container as a reflex response to a failed handler. That can discard progress and replay a large workload.

Safe handling of failed work

There are two different failures:

  • A transient downstream error may be suitable for bounded retries.
  • A permanently failing event needs a durable recovery path and a visible operational signal.

Returning success after silently discarding an event can advance progress past work that never completed. If the handler records failed work for later recovery, make that record durable before allowing the batch to checkpoint. Make replay idempotent.

Pull-mode exercise

Build a small consumer that reads a page, writes its derived result and persists the continuation state only after that work is safe. Restart the consumer after processing a page but before saving its token.

Check that replay does not duplicate the derived business effect. The saved token is an application responsibility in this model; creating an iterator does not automatically supply a durable checkpoint store.

Container copy jobs are a separate managed workflow

The current syllabus explicitly includes container copy jobs. They are useful when a supported migration needs a destination container, rather than trying to mutate a container’s partition-key definition in place.

Check supported account configuration, regions, permissions and tooling first. The documented CLI workflow uses the Cosmos DB preview extension:

az extension add --name cosmosdb-preview

For an online copy, create a job using the source and destination database/container settings. Inspect it using:

az cosmosdb copy show `
  --resource-group "<source-resource-group>" `
  --account-name "<source-account>" `
  --job-name "<copy-job>"

The job reports total and processed progress. A successful create command is not a completed migration.

Online-copy cutover

Follow the documented sequence:

  1. Monitor the job until it has caught up.
  2. Stop updates to the source when ready for final cutover.
  3. Allow the documented flush period for remaining changes.
  4. Complete the job with az cosmosdb copy complete.
  5. Validate the destination and update application routing.

Do not keep writing to both sides without an explicit synchronization design. Keep the source available for validation according to the migration plan; deleting it immediately after job creation removes your recovery path.

Question

Who owns continuation persistence in change feed pull mode?

Click or press Enter to reveal answer

Knowledge Check

A handler catches a failed downstream write and returns success without recording the event. What is the main risk?

Official references