An Azure service for ingesting, preparing, and transforming data at scale.
Yes, the MongoDB linked service database name can be parameterized in Azure Data Factory.
For MongoDB/MongoDB Atlas linked services, the database (or databaseName) property supports expressions, so it can be defined as a parameter instead of a fixed value.
High-level steps:
- Open the MongoDB (or MongoDB Atlas) linked service in ADF.
- Switch to the Code view (or enable Specify dynamic contents in JSON format under Advanced).
- Add a
parameterssection to the linked service JSON, for example:
For MongoDB Atlas, use{ "name": "LS_MongoDb", "properties": { "type": "MongoDbV2", "parameters": { "DatabaseName": { "type": "String" } }, "typeProperties": { "connectionString": "<your-connection-string>", "database": "@{linkedService().DatabaseName}" } } }type": "MongoDbAtlas"and"database": "@{linkedService().DatabaseName}". - Save the linked service.
- In each pipeline (or dataset) that uses this linked service, supply the appropriate database name value for
DatabaseNameat runtime.
This way, a single linked service can connect to multiple MongoDB databases by passing different parameter values, avoiding the need to create 20 separate linked services.
References: