1

オンプレミス SQL サーバーの SQL テーブルからデータをコピーし、Azure データ ファクトリ パイプラインのカスタム アクティビティを使用してドキュメント DB にアップロードしようとしています。IDotNetActivity またはその他のインターフェイスまたはクラスを使用してそれを達成する方法を教えてください。

4

4 に答える 4

2

実際、現在、カスタム アクティビティはオンプレミス データにアクセスできません。

同様の質問: Datafactory カスタム アクティビティで SqlException をスローするオンプレミス SQL 接続

ソリューションは、オンプレミス データをクラウドにコピーすることです。次に、クラウド ストレージに対してカスタム アクティビティを実行します。wBob は上記の良いサンプルを共有しました。

1 つのアクティビティで完了する必要がある場合は、vNet と ExpressRoute をセットアップして、Azure パブリック クラウドをオンプレミス環境に接続できます。

于 2016-10-13T18:09:06.967 に答える
1

これを従来の Azure Data Factory (ADF) タスクで動作させることができました。カスタム タスクは必要ありません。特にデバッグが難しいこれらのコンポーネントでは、必要以上に複雑にすることはありません。

次のサンプルは次を示しています。

  1. タイプOnPremisesSqlServerのリンクされたサービス。
  2. タイプDocumentDbのリンクされたサービス。
  3. タイプSQLServerDatasetの入力データセット。
  4. タイプDocumentDbCollectionの出力データセット。
  5. SqlSourceとDocumentDbCollectionSinkを使用するコピー アクティビティを含むパイプライン

タイプオンプレミス SQL Server のリンクされたサービス:

{
    "name": "OnPremLinkedService",
    "properties": {
        "type": "OnPremisesSqlServer",
        "description": "",
        "typeProperties": {
            "connectionString": "Data Source=<servername - required for credential encryption>;Initial Catalog=<databasename - required for credential encryption>;Integrated Security=False;User ID=<username>;Password=<password>;",
            "gatewayName": "<Name of the gateway that the Data Factory service should use to connect to the on-premises SQL Server database - required for credential encryption>",
            "userName": "<Specify user name if you are using Windows Authentication>",
            "password": "<Specify password for the user account>"
        }
    }
}

DocumentDB タイプのリンクされたサービス:

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

タイプ 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": {}
    }
}

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

SqlSource と 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"
    }
}
于 2016-10-09T11:25:49.183 に答える
0

ありがとうチャールズ。あなたが正しいことがわかりました。私が実装した解決策は次のとおりです。

パート1:

オンプレミス データベースからステージング DocumentDB コレクションにデータを移動するためのデータ ファクトリ パイプラインを実装しました。

パート2:

カスタム アクティビティを使用して、documentdb のさまざまなコレクション (ステージング) からのデータを結合し、必要な出力データを含む新しい documentdb コレクションを作成しました。

于 2016-10-18T12:52:58.920 に答える