Skip to content

feat: Cosmos DB Change Feed Mode Support#346

Open
swapnil-nagar wants to merge 4 commits into
Azure:devfrom
swapnil-nagar:swapnil/CosmosDBUpdate-Python
Open

feat: Cosmos DB Change Feed Mode Support#346
swapnil-nagar wants to merge 4 commits into
Azure:devfrom
swapnil-nagar:swapnil/CosmosDBUpdate-Python

Conversation

@swapnil-nagar

@swapnil-nagar swapnil-nagar commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Updated Python Azure Functions library to support Cosmos DB change feed modes (LatestVersion and AllVersionsAndDeletes), aligning with Azure WebJobs Extensions upstream implementation.

Changes

  • Type Definitions: Added CosmosDBChangeFeedMode type hint in _cosmosdb.py supporting 'LatestVersion' | 'AllVersionsAndDeletes'
  • Module Documentation: Updated CosmosDBConverter and CosmosDBTriggerConverter class docstrings to document change feed mode behavior
  • Public API: Exported CosmosDBChangeFeedMode type from main __init__.py for public consumption
  • Tests: Added 3 new unit tests validating change feed mode support:
    • test_cosmosdb_change_feed_mode_latest_version_support: Validates LatestVersion mode
    • test_cosmosdb_change_feed_mode_all_versions_and_deletes_support: Validates AllVersionsAndDeletes mode
    • test_cosmosdb_change_feed_mode_type_available: Verifies type availability in public API

Files Modified

  • azure/functions/_cosmosdb.py: Added CosmosDBChangeFeedMode type
  • azure/functions/cosmosdb.py: Updated documentation, exported type
  • azure/functions/__init__.py: Exported and documented CosmosDBChangeFeedMode
  • tests/test_cosmosdb.py: Added change feed mode tests

Alignment

This change mirrors the Node.js library v4.16.1 Cosmos DB updates, ensuring consistent change feed support across both runtimes.

- Added CosmosDBChangeFeedMode type supporting LatestVersion and AllVersionsAndDeletes modes
- Updated CosmosDBConverter and CosmosDBTriggerConverter documentation
- Exported CosmosDBChangeFeedMode from public API
- Added 3 unit tests for change feed mode support
- Updated version to 1.26.0
@swapnil-nagar swapnil-nagar changed the title Cosmos DB Change Feed Mode Support feat: Cosmos DB Change Feed Mode Support Jun 19, 2026
@swapnil-nagar

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 346 in repo Azure/azure-functions-python-library

Comment thread azure/functions/__init__.py Outdated
Comment thread azure/functions/cosmosdb.py
Comment thread azure/functions/_cosmosdb.py Outdated
@jviau

jviau commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

I am not familiar with E2E-test situation for this repo, but want to make sure the feature is validated either manually or by tests. A specific scenario to validate for is the incoming payload type when using AllVersionsAndDelete. With LatestVersion it will be T, for AVAD it will be ChangeFeedItem<T>. So the JSON representation of this CSharp class: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.changefeeditem-1?view=azure-dotnet-preview

Comment thread tests/test_cosmosdb.py
# then
self.assertTrue(is_exception_raised)

def test_cosmosdb_change_feed_mode_latest_version_support(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests for the decorator changes as well? You can add them under tests/decorators/test_cosmosdb.py - for reference, you can look at the Blob decorator tests with the source param (lines 11 - 69):

def test_blob_trigger_creation_with_no_source(self):

@hallvictoria

Copy link
Copy Markdown
Contributor

For Jacob's comment, our Cosmos DB E2E tests are defined here, and we use the Cosmos DB emulator.

If this feature is supported in the emulator, you can create a PR to the python worker repo with the new function apps & tests. If the feature is not supported, we can create a follow-up task to update the Cosmos tests when the emulators have this change. Please let me know if you have any questions for testing!

@hallvictoria

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jviau

jviau commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@hallvictoria I don't think it is supported in the emulator 😞. That has been the challenge with all my E2E tests also. I manually test with a real CosmosDB then disable the tests before checking in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants