Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO:
NoSQL
Azure Cosmos DB offers two change feed modes. Each mode offers the same core functionality. Differences include the operations that are captured in the feed, the metadata that's available for each change, and the retention period of changes. You can consume the change feed in different modes across multiple applications for the same Azure Cosmos DB container to fit the requirements of each workload. Each individual change feed application can only be configured to read change feed in one mode. Consuming the change feed in one mode doesn't prohibit you from consuming the change feed in another mode in a different application.
Note
Do you have any feedback about change feed modes? We want to hear it! Feel free to share feedback directly with the Azure Cosmos DB engineering team: cosmoschangefeed@microsoft.com.
Latest version mode is a persistent record of changes made to items from creates and updates. You get the latest version of each item in the container. For example, if an item is created and then updated before you read the change feed, only the updated version appears in the change feed. Deletes aren't captured as changes, and when an item is deleted, it's no longer be available in the feed. Latest version change feed mode is enabled by default and is compatible with all Azure Cosmos DB accounts except the API for Table and the API for PostgreSQL. This mode was previously the default way to consume the change feed.
All versions and deletes mode (preview) is a persistent record of all changes to items from create, update, and delete operations. You get a record of each change to items in the order that it occurred, including intermediate changes to an item between change feed reads. For example, if an item is created and then updated before you read the change feed, both the create and the update versions of the item appear in the change feed. To read from the change feed in all versions and deletes mode, you must have continuous backups configured for your Azure Cosmos DB account. Turning on continuous backups creates the all versions and deletes change feed. You can only read changes that occurred within the continuous backup period when using this change feed mode. This mode is only compatible with Azure Cosmos DB for NoSQL accounts. Learn more about how to sign up for the preview.
The all versions and deletes change feed mode enables new scenarios for change feed, and simplifies others. You can read every change that occurred to items (even in cases in which multiple changes occurred between change feed reads), identify the operation type of changes being processed, and get changes that result from deletes.
A few common scenarios this mode enables and enhances are:
Real-time transfer of data between two locations without implementing a soft delete.
Triggering logic based on incremental changes if multiple change operations for a given item are expected between change feed polls.
Triggering alerts on delete operations, like in auditing scenarios.
The ability to process item creates, updates, and deletes differently based on operation type.
In addition to the common features across all change feed modes, each change feed mode has the following characteristics:
The change feed includes insert, update, and delete operations made to items within the container. Deletes from TTL expirations are also captured.
Metadata is provided to determine the change type, including whether a delete was due to a TTL expiration.
Change feed items come in the order of their modification time. Deletes from TTL expirations aren't guaranteed to appear in the feed immediately after the item expires. They appear when the item is purged from the container.
All changes that occurred within the retention window for continuous backups on the account can be read. Attempting to read changes that occurred outside of the retention window results in an error. For example, if your container was created eight days ago and your continuous backup period retention period is seven days, then you can only read changes from the last seven days.
The change feed starting point can be from "now" or from a specific checkpoint within your retention period. You can't read changes from the beginning of the container or from a specific point in time by using this mode.
Each mode is compatible with different methods to read the change feed for each language.
During the preview, the following methods to read the change feed are available for each client SDK:
Method to read change feed | .NET | Java | Python | Node.js |
---|---|---|---|---|
Change feed pull model | >= 3.32.0-preview | >= 4.42.0 | >= 4.9.1b1 | >= 4.1.0 |
Change feed processor | >= 3.40.0-preview.0 | >= 4.42.0 | No | No |
Azure Functions trigger | No | No | No | No |
Note
Regardless of the connection mode that's configured in your application, all requests made with all versions and deletes change feed will use Gateway mode.
To get started using all versions and deletes change feed mode, navigate to the Features page in your Azure Cosmos DB account. Select and enable the All versions and deletes change feed mode (preview) feature. You must have continuous backups configured for your Azure Cosmos DB account before enabling the feature. The enablement process can take up to 30 minutes to be complete and no other changes can be made to the account during this time.
Alternately, enable all versions and deletes mode with the REST API by adding "enableAllVersionsAndDeletesChangeFeed" : true
to the properties
of your account. This property is available in preview API version 2024-12-01-preview
or later.
The response object is an array of items that represent each change. Different properties will be populated depending on the change type. There's currently no way to get the previous version of items for either replace or delete operations.
Create operations
{ "current": { <The current version of the item that changed. All the properties of your item will appear here.> }, "metadata": { "operationType": "create", "lsn": <A number that represents the batch ID. Many items can have the same lsn.>, "crts": <A number that represents the Conflict Resolved Timestamp. It has the same format as _ts.> } }
Replace operations
{ "current": { <The current version of the item that changed. All the properties of your item will appear here.> }, "metadata": { "operationType": "replace", "lsn": <A number that represents the batch ID. Many items can have the same lsn.>, "crts": <A number that represents the Conflict Resolved Timestamp. It has the same format as _ts.>, "previousImageLSN" : <A number that represents the batch ID of the change prior to this one.>, } }
Delete operations
{ "metadata": { "operationType": "delete", "lsn": <A number that represents the batch ID. Many items can have the same lsn.>, "crts": <A number that represents the Conflict Resolved Timestamp. It has the same format as _ts.>, "previousImageLSN" : <A number that represents the batch ID of the change prior to this one.>, "timeToLiveExpired" : <'true' if it was deleted due to a TTL expiration.>, "id": "<Id of the deleted item.>", "partitionKey": { "<Partition key property name>": "<Partition key property value>" } } }
Supported for Azure Cosmos DB for NoSQL accounts. Other Azure Cosmos DB account types aren't supported.
Continuous backups are required to use this change feed mode. Refer to the limitations of using continuous backups.
Reading changes on a container that existed before continuous backups were enabled on the account isn't supported.
The ability to start reading the change feed from the beginning or to select a start time based on a past time stamp isn't currently supported. You can either start from "now" or from a previous lease or continuation token.
Receiving the previous version of items that were deleted or updated isn't currently available.
Accounts that enabled merging partitions aren't supported.
Learn more about change feed in the following articles: