0
votes

I'm trying to parameterize the mongo DB connection's linked service in azure data factory. I have referred the document here. Below is the code I'm trying to update in the code of the linked service

{
"name": "MongoDB",
"properties": {
    "type": "MongoDbV2",
    "parameters": {
        "LSHeatStackConnection": {
            "type": "String",
            "defaultValue": "mongodb://username:password@1.1.1.4:1800/dbname?authMechanism=SCRAM-SHA-1;authSource=admin"
        }
    },
    "annotations": [],
    "typeProperties": {
        "connectionString": {
            "type": "SecureString",
            "value": "@{linkedService().LSHeatStackConnection}"
        },
        "database": "heatstack"
    },
    "connectVia": {
        "referenceName": "DevIR",
        "type": "IntegrationRuntimeReference"
    }
}
}

But I'm getting the below error while saving the above code.

Failed to publish ****DB(linked service name). Reason: At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.

When I try edit the linked service by clicking the pencil iconenter image description here, and click on test connection it says success. But when I click finish it throws error and it says Failed to save *****DB. Error: Failed to encrypt sub-resource payload

Below is the screenshot of the error. enter image description here

1

1 Answers

1
votes

Mongo DB (or Cosmos DB Mongo API)’s connection string format is different from other connectors’ which are key/value pairs, so it cannot fit payload encryption framework with parameters which requires the connection string’s format as key value pair when it’s parameterized; and it will fail if any parameter is specified in connection string during payload encryption.

As of now we can't directly parameterize the connection string for MongoDB. We have to store the Connection String in the Key Vault and then pass the secret value as a parameter. That is the only way to parameterize a mongoDB linked Services

If you have any feedback/suggestion related to this please share it in Azure Data Factory User voice forum