Skip to content

Add Azure Cosmos DB for MongoDB trigger, input, and output bindings#418

Open
xingfan-git wants to merge 10 commits into
v4.xfrom
xingfan/onboarding_mongodb_extension_nodejs
Open

Add Azure Cosmos DB for MongoDB trigger, input, and output bindings#418
xingfan-git wants to merge 10 commits into
v4.xfrom
xingfan/onboarding_mongodb_extension_nodejs

Conversation

@xingfan-git
Copy link
Copy Markdown

Summary

This PR adds Node.js SDK support for the Azure Cosmos DB for MongoDB bindings, enabling
developers to trigger functions on MongoDB change stream events and read/write documents
from MongoDB collections using the Azure Functions programming model.

Changes

New Features

  • app.cosmosDBMongo() — New function registration method for Cosmos DB for MongoDB
    triggered functions
  • trigger.cosmosDBMongo() — New trigger factory for monitoring MongoDB change streams
    (supports Collection / Database / Cluster level)
  • input.cosmosDBMongo() — New input binding factory for reading documents from a MongoDB
    collection, with optional queryString filter support
  • output.cosmosDBMongo() — New output binding factory for upserting documents into a
    MongoDB collection
  • Type definitions for CosmosDBMongoTriggerOptions, CosmosDBMongoTrigger,
    CosmosDBMongoFunctionOptions, CosmosDBMongoHandler, CosmosDBMongoInputOptions,
    CosmosDBMongoInput, CosmosDBMongoOutputOptions, and CosmosDBMongoOutput

Binding Type Strings

Binding Type string
Trigger cosmosDBMongoTrigger
Input cosmosDBMongo
Output cosmosDBMongo

Tests

Added test/cosmosDBMongo.test.ts with 12 test cases covering trigger, input, and output —
verifying type strings, all binding options, deterministic binding name generation, and
correct direction values via toCoreFunctionMetadata.

@xingfan-git xingfan-git requested a review from a team as a code owner March 27, 2026 03:04
@swapnil-nagar
Copy link
Copy Markdown
Contributor

@xingfan-git do you have a sample app, which would help me validate the changes?

Copy link
Copy Markdown
Contributor

@swapnil-nagar swapnil-nagar left a comment

Choose a reason for hiding this comment

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

Sample app to validate this change

@xingfan-git xingfan-git reopened this Apr 20, 2026
@xingfan-git
Copy link
Copy Markdown
Author

@swapnil-nagar I have added sample code in this repo. If you need a connection string, please let me know

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds first-class Node.js programming model support for Azure Cosmos DB for MongoDB bindings, including a new trigger plus input/output binding factories and a sample app.

Changes:

  • Adds cosmosDBMongo trigger/input/output factories and app.cosmosDBMongo() registration support.
  • Introduces public TypeScript types for Cosmos DB Mongo trigger/input/output options and handler signatures.
  • Adds unit tests and a new end-to-end-ish sample project demonstrating usage.

Reviewed changes

Copilot reviewed 14 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
types/trigger.d.ts Exposes trigger.cosmosDBMongo() in public typings.
types/input.d.ts Exposes input.cosmosDBMongo() in public typings.
types/output.d.ts Exposes output.cosmosDBMongo() in public typings.
types/app.d.ts Exposes app.cosmosDBMongo() registration signature.
types/index.d.ts Re-exports new Cosmos DB Mongo types.
types/cosmosDBMongo.d.ts Adds new public option/handler/binding type definitions.
src/trigger.ts Implements trigger.cosmosDBMongo() factory with deterministic binding naming.
src/input.ts Implements input.cosmosDBMongo() factory with deterministic binding naming.
src/output.ts Implements output.cosmosDBMongo() factory with deterministic binding naming.
src/app.ts Implements app.cosmosDBMongo() registration via generic registration path.
test/cosmosDBMongo.test.ts Adds unit tests validating type strings, option copying, name determinism, and binding directions.
sample/cosmosDBMongo/* Adds a runnable sample showcasing trigger + HTTP read/write via input/output bindings.
Files not reviewed (1)
  • sample/cosmosDBMongo/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sample/cosmosDBMongo/local.settings.json Outdated
Comment thread sample/cosmosDBMongo/package-lock.json Outdated
Comment thread sample/cosmosDBMongo/extensions.csproj Outdated
Comment thread sample/cosmosDBMongo/src/functions/httpGetDocuments.ts Outdated
Comment thread types/cosmosDBMongo.d.ts
Comment thread test/cosmosDBMongo.test.ts
@swapnil-nagar
Copy link
Copy Markdown
Contributor

Also, as explained this changes will be in preview, hence lets make changes in the package.json with version 4.15.0-preview

@xingfan-git
Copy link
Copy Markdown
Author

PR for e2e test: Azure/azure-functions-nodejs-e2e-tests#88
But I suppose it needs to wait this PR merged as it needs the 4.15.0-preview package

@swapnil-nagar
Copy link
Copy Markdown
Contributor

PR for e2e test: Azure/azure-functions-nodejs-e2e-tests#88 But I suppose it needs to wait this PR merged as it needs the 4.15.0-preview package

Yes, but that would be a task that you will need after this PR goes through.

@xingfan-git
Copy link
Copy Markdown
Author

@swapnil-nagar I've updated the version to 4.16-preview as current version in v4.x is already 4.15, if it's not correct, please let me know.
The e2e test I have tested locally. Will update to proper version after this PR got merged

@xingfan-git xingfan-git requested a review from swapnil-nagar May 15, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants