Problem while connecting azure data factory to Azure Cosmos DB with Mongo DB API

Steffen Klempau 1 Reputation point
2021-11-29T16:29:10.547+00:00

Hi,

we are trying to connect from Data Factory (ADF) to an Azure Cosmos DB with MongoDB Api. The DB is hosted by a third party which has granted access to a specific IP-Address range. Therefore, we are using a self hosted integration runtime. We've set up the Self Hosted IR and are using it with the linked service in ADF. We are using the linked service type "(Azure Cosmos DB (MongoDB API)" and trying to connect to a connection string in the following format: 'mongodb://<account-name>:<password>@<account-name>.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=<account-name>'. When we are trying to connect to the DB, we are receiving the following error:

"EndPoint: "Unspecified/s<account-name>.mongo.cosmos.azure.com:10255", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)"

The mongo db version is 3.6.0 and we have successfully verified the connection string via a local client (Darwin, mongosh cli). We already tested different versions and format for the connection string. We still cant connect.

Does anyone have any clue?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,437 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,486 questions
{count} votes

2 answers

Sort by: Most helpful
  1. ShaikMaheer-MSFT 37,896 Reputation points Microsoft Employee
    2021-12-01T14:10:49.45+00:00

    Hi @Steffen Klempau ,

    Thank you for posting ask in Microsoft Q&A Platform.

    Below are some observations. Could you please correct them and try.

    For 3.2 server version, the string pattern is mongodb://<cosmosdb-name>:<password>@<cosmosdb-name>.documents.azure.com:10255/?ssl=true&replicaSet=globaldb

    For 3.6+ server versions, the string pattern is mongodb://<cosmosdb-name>:<password>@<cosmosdb-name>.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000&appName=@<cosmosdb-name>@

    It seems in your case, you used 3.6+ version pattern. But @ Symbols missing for appName=@<cosmosdb-name>@ Kindly include them and try. If not, Still not works kindly feel free to try 3.2 version format as well.

    Kindly cross check and make sure you have set "isServerVersionAbove32" value to true.

    Please let us know how it goes. Please let us know if any further queries.

    0 comments No comments

  2. Guosen Wang 1 Reputation point Microsoft Employee
    2021-12-08T08:03:40.753+00:00

    Hi @Steffen Klempau , this is Guosen from ADF development team.
    From the error message I think it's a network issue between SHIR machine and cosmos mongo server. I want to know your local verification was performed on the SHIR machine, or another machine?