Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Implement a change feed processor to detect and handle new or updated items

A worked example

Yes or no

A support team stores troubleshooting guides in the knowledge-base container of the support-db database in an Azure Cosmos DB for NoSQL account. The container was created with default settings, and nothing about it has been changed since.

The team wants embeddings to be regenerated automatically whenever a guide is inserted or updated. They deploy a Python function app that contains the function shown in the exhibit.

# Excerpt from function_app.py
@app.cosmos_db_trigger(
    arg_name="documents",
    container_name="knowledge-base",
    database_name="support-db",
    connection="CosmosDBConnection",
    lease_container_name="leases",
    create_lease_container_if_not_exists=True
)
def refresh_embeddings(documents: func.DocumentList):
    ...

For each of the following statements, select Yes if the statement is true. Otherwise, select No.
StatementYesNo
The team must turn on the change feed for the knowledge-base container before the function can receive inserted or updated guides.

The change feed is on by default for every container and needs no extra configuration. The container in this scenario uses default settings, so nothing has to be turned on.

Correct
The function uses the leases container to keep checkpoints that record how far it has processed the change feed.

The Cosmos DB trigger keeps checkpoints to track its processing progress. The trigger configuration names leases as the lease container for this purpose.

Correct
When several guides that share the same partition key value are updated, the function receives those changes in the order in which they were modified.

The change feed delivers changes within a partition key in the order the modifications happened.

Correct
Why

The change feed is a persistent, ordered log of inserts and updates. It is on by default for all containers, so the default knowledge-base container needs no extra setup. The Cosmos DB trigger reads that feed and checkpoints its progress in the lease container named in the configuration, here leases. Ordering is guaranteed within a partition key, so changes to guides that share a partition key value arrive in modification order.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free