Copy From OnPrem SQL server to DocumentDB using custom activity in ADF Pipeline

后端 未结 4 668
予麋鹿
予麋鹿 2021-01-24 09:56

I am trying to copy data from SQL Table in a on-prem sql server and upload it to a Document DB using custom activity in Azure data factory pipeline. Can anyone tell me how can I

4条回答
  •  攒了一身酷
    2021-01-24 10:38

    I got this to work with conventional Azure Data Factory (ADF) tasks. No custom task is required. I wouldn't make things more complicated than they need to be particularly with these components which can be hard to debug.

    The following sample shows:

    1. A linked service of type OnPremisesSqlServer.
    2. A linked service of type DocumentDb.
    3. An input dataset of type SQLServerDataset.
    4. An output dataset of type DocumentDbCollection.
    5. The pipeline with Copy activity that uses SqlSource and DocumentDbCollectionSink.

    Linked Service of type On Premises SQL Server:

    {
        "name": "OnPremLinkedService",
        "properties": {
            "type": "OnPremisesSqlServer",
            "description": "",
            "typeProperties": {
                "connectionString": "Data Source=;Initial Catalog=;Integrated Security=False;User ID=;Password=;",
                "gatewayName": "",
                "userName": "",
                "password": ""
            }
        }
    }
    

    Linked Service of type DocumentDB:

    {
        "name": "DocumentDbLinkedService",
        "properties": {
            "type": "DocumentDb",
            "typeProperties": {
                "connectionString": "AccountEndpoint=;AccountKey=;Database="
            }
        }
    }
    

    Input Dataset of type SqlServerTable:

    {
        "name": "SQLServerDataset",
        "properties": {
            "structure": [
                {
                    "name": "Id",
                    "type": "Int32"
                },
                {
                    "name": "FirstName",
                    "type": "String"
                },
                {
                    "name": "MiddleName",
                    "type": "String"
                },
                {
                    "name": "LastName",
                    "type": "String"
                }
            ],
            "published": false,
            "type": "SqlServerTable",
            "linkedServiceName": "OnPremLinkedService",
            "typeProperties": {
                "tableName": "dbo.Users"
            },
            "availability": {
                "frequency": "Day",
                "interval": 1
            },
            "external": true,
            "policy": {}
        }
    }
    

    Output Dataset of type DocumentDbCollection:

    {
        "name": "PersonDocumentDbTableOut",
        "properties": {
            "structure": [
                {
                    "name": "Id",
                    "type": "Int32"
                },
                {
                    "name": "Name.First",
                    "type": "String"
                },
                {
                    "name": "Name.Middle",
                    "type": "String"
                },
                {
                    "name": "Name.Last",
                    "type": "String"
                }
            ],
            "published": false,
            "type": "DocumentDbCollection",
            "linkedServiceName": "DocumentDbLinkedService",
            "typeProperties": {
                "collectionName": "Person"
            },
            "availability": {
                "frequency": "Day",
                "interval": 1
            }
        }
    }
    

    Pipeline with Copy activity using SqlSource and DocumentDbCollectionSink:

    {
        "name": "PipelineTemplate 3",
        "properties": {
            "description": "On prem to DocDb test",
            "activities": [
                {
                    "type": "Copy",
                    "typeProperties": {
                        "source": {
                            "type": "SqlSource"
                        },
                        "sink": {
                            "type": "DocumentDbCollectionSink",
                            "writeBatchSize": 2,
                            "writeBatchTimeout": "00:00:00"
                        },
                        "translator": {
                            "type": "TabularTranslator",
                            "columnMappings": "id: id, FirstName: Name.First, MiddleName: Name.Middle, LastName: Name.Last"
                        }
                    },
                    "inputs": [
                        {
                            "name": "SQLServerDataset"
                        }
                    ],
                    "outputs": [
                        {
                            "name": "PersonDocumentDbTableOut"
                        }
                    ],
                    "policy": {
                        "timeout": "1.00:00:00",
                        "concurrency": 1,
                        "retry": 3
                    },
                    "scheduler": {
                        "frequency": "Day",
                        "interval": 1
                    },
                    "name": "CopyActivityTemplate"
                }
            ],
            "start": "2016-10-05T00:00:00Z",
            "end": "2016-10-05T00:00:00Z",
            "isPaused": false,
            "hubName": "adfdocdb2_hub",
            "pipelineMode": "Scheduled"
        }
    }
    

提交回复
热议问题