Skip to main content

Configuring an ADF Linked Service Connection for MongoDB

note

For information on how to enable a connection for use with linked services, see Configuring a Linked Service Connection.

After selecting MongoDB from the Linked Service Type dropdown, the form required for creating a MongoDB Linked Service will appear. The MongoDB option is offered on connections that use the MongoDB System Type.

BimlFlex writes the current Azure Data Factory MongoDB connector, with the linked service type MongoDbV2. The Microsoft documentation states that this connector supports MongoDB versions up to 4.2.

Datasets, Sources and Sinks​

A MongoDB connection serves the source system, the landing area and the persistent landing area stages.

The dataset addresses each object as a collection, taking the collection name from the TargetObjectName parameter.

Each MongoDB object is copied whole from its collection. The copy has no source query and passes the TargetSchemaName and TargetObjectName parameters to the dataset.

The copy source reads the setting keys below from the object's settings. Each key is a setting of the Setting Editor's Azure group, in the section Data Factory Copy Source Members, with the label the table names. These settings are blank by default. A value reaches an object as a Setting Override on that object. Add on the Azure group's Overrides tab opens the Add Setting Override form, where the Attribute Type is Object, the Connection and the Object select the object, the Setting is picked by its label (shown as Filter (Data Factory Copy Source Members)), and the Override Value holds the member's text. A key that is empty or holds the default in the table is not written to the copy source.

Setting KeyLabelADF PropertyDefault
filterFilterfilterNo default
batchSizeBatch SizebatchSize100
cursorMethods.projectCursor ProjectcursorMethods.projectNo default
cursorMethods.sortCursor SortcursorMethods.sortNo default
cursorMethods.limitCursor LimitcursorMethods.limit0
cursorMethods.skipCursor SkipcursorMethods.skip0

As a landing area or persistent landing area in a Data Factory or Fabric data pipeline project, the connection is the target of the copy. The copy sink writes to the collection the dataset names, and the copy passes the TargetSchemaName and TargetObjectName parameters to the dataset.

The sink carries no pre copy script. Documents are inserted into the collection by default, and replaced by key when the object's write behavior setting is upsert. The write behavior setting is the writeBehavior setting key of the object. The write batch size and the other sink members keep their defaults.

Choosing an Authentication Method​

MethodCredentialsAdditional Settings
Connection StringThe user name and password inside the Connection StringNone

Recommendation: Store the Connection String in Azure Key Vault rather than entering it as plaintext, since it carries the password.

Complete Example: Connection String with Azure Key Vault​

FieldExample Value
Connect via Integration RuntimeAutoResolveIntegrationRuntime
Database Namesales
Azure Key Vault Linked Servicebfx-kv
Secret Name (for Connection String)BFX-SRC-MongoDbConnectionString

The secret holds the whole connection string, for example mongodb://bfx_reader:<password>@mongo01.contoso.com:27017/sales.

Required Fields​

Common Required Fields

A MongoDB Linked Service connection uses a single Authentication Type, so the same fields are required on every connection.

These common required fields are:

Connect via Integration Runtime​

Connect via Integration Runtime names the integration runtime for a MongoDB Linked Service connection. The default value is AutoResolveIntegrationRuntime. To use a custom runtime, select one of the Azure Integration Runtimes saved in BimlFlex settings, or select + New and enter the name of the runtime. A runtime added through + New is saved to the custom integration runtimes. The custom values that appear in this dropdown can be maintained in Settings under Azure - AzureIntegrationRuntime.

The runtime is stored in the connection's LS_ConnectVia_IntegrationRuntime column. Any value other than AutoResolveIntegrationRuntime is written to the linked service as the runtime it connects through.

Azure Data Factory connects to MongoDB through the Azure integration runtime when the data store is a managed cloud data service. A data store inside an on-premises network, an Azure virtual network or an Amazon Virtual Private Cloud needs a self-hosted integration runtime.

Connection String​

The Connection String identifies the MongoDB server and carries the user name and password, in the form mongodb://[username:password@]host[:port][/[database][?options]] (for example, mongodb://bfx_reader:<password>@mongo01.contoso.com:27017/sales). The Connection String field accepts the value as plaintext in the LS_ConnectionString column, or an Azure Key Vault reference on the Connection String (Azure Key Vault) tab, stored in the LS_ConnectionStringKVS_ fields, that resolves to the connection string at runtime. It maps to the ADF connectionString property.

note

It is suggested that Azure Key Vault be used in place of manually entering the Connection String.

Database Name​

The Database Name names the MongoDB database the connector reads from (for example, sales). It is stored in the connection's LS_Db column and maps to the ADF database property.

Azure Data Factory Linked Service Additional Information​

For additional information on ADF MongoDB Linked Service and its connection requirements see the Azure Data Factory MongoDB Connector documentation.