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
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:
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"
}
}