Repository navigation
Add IdFieldName parameter to MongoDB sink extensions for custom _id mapping - #208
Merged
Mark Brown (markjbrown) merged 5 commits intoNov 4, 2025
Conversation
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] mapping cosmos-nosql id to mongodb _id
Add IdFieldName parameter to MongoDB sink extensions for custom _id mapping
Oct 1, 2025
Phil Nachreiner (philnach)
marked this pull request as ready for review
November 4, 2025 20:35
Phil Nachreiner (philnach)
requested review from
John Bowen (bowencode) and
Mark Brown (markjbrown)
November 4, 2025 20:35
Phil Nachreiner (philnach)
approved these changes
Nov 4, 2025
Phil Nachreiner (philnach)
left a comment
Collaborator
There was a problem hiding this comment.
I verified the behavior and change looks good to me.
Mark Brown (markjbrown)
approved these changes
Nov 4, 2025
Collaborator
|
Thanks Phil Nachreiner (@philnach) !!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When migrating data from Cosmos DB NoSQL to MongoDB, the tool was generating new ObjectIds for MongoDB's
_idfield instead of preserving the source document'sidfield. This made it difficult to maintain consistent identifiers across systems.For example, with source data:
{ "id": "BSKT_1", "CustomerId": 111 }The tool would create:
{ "_id": ObjectId("659f9bbcb128ee4f195bdf8d"), "id": "BSKT_1", "CustomerId": 111 }Solution
This PR adds an optional
IdFieldNameparameter to the MongoDB sink settings that allows users to specify which field from the source data should be mapped to MongoDB's_idfield. The original field is also preserved in the document.Usage
{ "Source": "Cosmos-NoSql", "Sink": "MongoDB", "SourceSettings": { "ConnectionString": "AccountEndpoint=https://...", "Database": "cosmicworks", "Container": "baskets" }, "SinkSettings": { "ConnectionString": "mongodb://localhost:27017", "DatabaseName": "mydb", "Collection": "baskets", "IdFieldName": "id" } }With this configuration, the result in MongoDB will be:
{ "_id": "BSKT_1", "id": "BSKT_1", "CustomerId": 111 }Changes
IdFieldNameproperty toMongoSinkSettingsandMongoLegacySinkSettingsMongoDataSinkExtensionandMongoLegacyDataSinkExtensionto map the specified field to_idREADME.mdandExampleConfigs.mdFeatures
_idFixes #[issue-number]
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
http://crl3.digicert.com:443/sha2-assured-cs-g1.crldotnet build Extensions/Mongo/Cosmos.DataTransfer.MongoExtension/Cosmos.DataTransfer.MongoExtension.csproj(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.