使用 Azure 数据工厂从 SAP Cloud for Customer (C4C) 复制数据Copy data from SAP Cloud for Customer (C4C) using Azure Data Factory

本文概述如何使用 Azure 数据工厂中的复制活动从/向 SAP Cloud for Customer (C4C) 复制数据。This article outlines how to use the Copy Activity in Azure Data Factory to copy data from/to SAP Cloud for Customer (C4C). 它是基于概述复制活动总体的复制活动概述一文。It builds on the copy activity overview article that presents a general overview of copy activity.

Tip

若要了解 ADF 对 SAP 数据集成方案的总体支持,请参阅使用 Azure 数据工厂进行 SAP 数据集成白皮书,其中包含详细介绍、比较和指导。To learn ADF's overall support on SAP data integration scenario, see SAP data integration using Azure Data Factory whitepaper with detailed introduction, comparsion and guidance.

支持的功能Supported capabilities

以下活动支持此 SAP Cloud for Customer 连接器:This SAP Cloud for Customer connector is supported for the following activities:

可将数据从 SAP Cloud for Customer 复制到任何受支持的接收器数据存储,或者将数据从任何受支持的源数据存储复制到 SAP Cloud for Customer。You can copy data from SAP Cloud for Customer to any supported sink data store, or copy data from any supported source data store to SAP Cloud for Customer. 有关复制活动支持作为源/接收器的数据存储列表,请参阅支持的数据存储表。For a list of data stores that are supported as sources/sinks by the copy activity, see the Supported data stores table.

具体而言,此连接器使 Azure 数据工厂能够将数据从/向 SAP Cloud for Customer(包括 SAP Cloud for Sales、SAP Cloud for Service 和 SAP Cloud for Social Engagement 解决方案)复制数据。Specifically, this connector enables Azure Data Factory to copy data from/to SAP Cloud for Customer including the SAP Cloud for Sales, SAP Cloud for Service, and SAP Cloud for Social Engagement solutions.

入门Getting started

可以通过以下工具或 SDK 之一结合使用复制活动和管道。You can use one of the following tools or SDKs to use the copy activity with a pipeline. 选择链接,查看分步说明:Select a link for step-by-step instructions:

对于特定于 SAP Cloud for Customer 连接器的数据工厂实体,以下部分提供有关用于定义这些实体的属性的详细信息。The following sections provide details about properties that are used to define Data Factory entities specific to SAP Cloud for Customer connector.

链接服务属性Linked service properties

SAP Cloud for Customer 链接服务支持以下属性:The following properties are supported for SAP Cloud for Customer linked service:

属性Property 说明Description 必选Required
typetype type 属性必须设置为:SapCloudForCustomerThe type property must be set to: SapCloudForCustomer. Yes
urlurl SAP C4C OData 服务的 URL。The URL of the SAP C4C OData service. Yes
usernameusername 指定用于连接到 SAP C4C 的用户名。Specify the user name to connect to the SAP C4C. Yes
passwordpassword 指定为 username 指定的用户帐户的密码。Specify the password for the user account you specified for the username. 将此字段标记为 SecureString 以安全地将其存储在数据工厂中或引用存储在 Azure Key Vault 中的机密Mark this field as a SecureString to store it securely in Data Factory, or reference a secret stored in Azure Key Vault. Yes
connectViaconnectVia 用于连接到数据存储的集成运行时The Integration Runtime to be used to connect to the data store. 如果未指定,则使用默认 Azure Integration Runtime。If not specified, it uses the default Azure Integration Runtime. 对于源为“No”,对于接收器为“Yes”No for source, Yes for sink

Important

若要将数据复制到 SAP Cloud for Customer,请显式使用接近 SAP Cloud for Customer 的位置创建 Azure IR,并按如下示例关联链接服务:To copy data into SAP Cloud for Customer, explicitly create an Azure IR with a location near your SAP Cloud for Customer, and associate in the linked service as the following example:

示例:Example:

{
    "name": "SAPC4CLinkedService",
    "properties": {
        "type": "SapCloudForCustomer",
        "typeProperties": {
            "url": "https://<tenantname>.crm.ondemand.com/sap/c4c/odata/v1/c4codata/" ,
            "username": "<username>",
            "password": {
                "type": "SecureString",
                "value": "<password>"
            }
        },
        "connectVia": {
            "referenceName": "<name of Integration Runtime>",
            "type": "IntegrationRuntimeReference"
        }
    }
}

数据集属性Dataset properties

有关可用于定义数据集的各部分和属性的完整列表,请参阅数据集一文。For a full list of sections and properties available for defining datasets, see the datasets article. 本部分提供 SAP Cloud for Customer 数据集支持的属性列表。This section provides a list of properties supported by SAP Cloud for Customer dataset.

若要从 SAP Cloud for Customer 复制数据,请将数据集的 type 属性设置为 SapCloudForCustomerResourceTo copy data from SAP Cloud for Customer, set the type property of the dataset to SapCloudForCustomerResource. 支持以下属性:The following properties are supported:

属性Property 说明Description 必选Required
typetype 数据集的 type 属性必须设置为:SapCloudForCustomerResourceThe type property of the dataset must be set to: SapCloudForCustomerResource Yes
pathpath 指定 SAP C4C OData 实体的路径。Specify path of the SAP C4C OData entity. Yes

示例:Example:

{
    "name": "SAPC4CDataset",
    "properties": {
        "type": "SapCloudForCustomerResource",
        "typeProperties": {
            "path": "<path e.g. LeadCollection>"
        },
        "schema": [],
        "linkedServiceName": {
            "referenceName": "<SAP C4C linked service>",
            "type": "LinkedServiceReference"
        }
    }
}

复制活动属性Copy activity properties

有关可用于定义活动的各部分和属性的完整列表,请参阅管道一文。For a full list of sections and properties available for defining activities, see the Pipelines article. 本部分提供 SAP Cloud for Customer 源支持的属性列表。This section provides a list of properties supported by SAP Cloud for Customer source.

以 SAP C4C 作为源SAP C4C as source

若要从 SAP Cloud for Customer 复制数据,请将复制活动中的源类型设置为 SapCloudForCustomerSourceTo copy data from SAP Cloud for Customer, set the source type in the copy activity to SapCloudForCustomerSource. 复制活动source部分支持以下属性:The following properties are supported in the copy activity source section:

属性Property 说明Description 必选Required
typetype type 属性必须设置为:SapCloudForCustomerSourceThe type property must be set to: SapCloudForCustomerSource Yes
查询query 指定用于读取数据的自定义 OData 查询。Specify the custom OData query to read data. No

用于获取特定天数据的示例查询:"query": "$filter=CreatedOn ge datetimeoffset'2017-07-31T10:02:06.4202620Z' and CreatedOn le datetimeoffset'2017-08-01T10:02:06.4202620Z'"Sample query to get data for a specific day: "query": "$filter=CreatedOn ge datetimeoffset'2017-07-31T10:02:06.4202620Z' and CreatedOn le datetimeoffset'2017-08-01T10:02:06.4202620Z'"

示例:Example:

"activities":[
    {
        "name": "CopyFromSAPC4C",
        "type": "Copy",
        "inputs": [
            {
                "referenceName": "<SAP C4C input dataset>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<output dataset>",
                "type": "DatasetReference"
            }
        ],
        "typeProperties": {
            "source": {
                "type": "SapCloudForCustomerSource",
                "query": "<custom query e.g. $top=10>"
            },
            "sink": {
                "type": "<sink type>"
            }
        }
    }
]

以 SAP C4C 作为接收器SAP C4C as sink

若要将数据复制到 SAP Cloud for Customer,请将复制活动中的接收器类型设置为 SapCloudForCustomerSinkTo copy data to SAP Cloud for Customer, set the sink type in the copy activity to SapCloudForCustomerSink. 复制活动接收器部分中支持以下属性 :The following properties are supported in the copy activity sink section:

属性Property 说明Description 必选Required
typetype type 属性必须设置为:SapCloudForCustomerSinkThe type property must be set to: SapCloudForCustomerSink Yes
writeBehaviorwriteBehavior 操作的写入行为。The write behavior of the operation. 可以是“Insert”、“Update”。Could be “Insert”, “Update”.  否。No. 默认值为“Insert”。Default “Insert”.
writeBatchSizewriteBatchSize 写入操作的批大小。The batch size of write operation. 可获得最佳性能的批大小可能会因不同表或服务器而异。The batch size to get best performance may be different for different table or server. 否。No. 默认值为 10。Default 10. 

示例:Example:

"activities":[
    {
        "name": "CopyToSapC4c",
        "type": "Copy",
        "inputs": [{
            "type": "DatasetReference",
            "referenceName": "<dataset type>"
        }],
        "outputs": [{
            "type": "DatasetReference",
            "referenceName": "SapC4cDataset"
        }],
        "typeProperties": {
            "source": {
                "type": "<source type>"
            },
            "sink": {
                "type": "SapCloudForCustomerSink",
                "writeBehavior": "Insert",
                "writeBatchSize": 30
            },
            "parallelCopies": 10,
            "dataIntegrationUnits": 4,
            "enableSkipIncompatibleRow": true,
            "redirectIncompatibleRowSettings": {
                "linkedServiceName": {
                    "referenceName": "ErrorLogBlobLinkedService",
                    "type": "LinkedServiceReference"
                },
                "path": "incompatiblerows"
            }
        }
    }
]

SAP Cloud for Customer 的数据类型映射Data type mapping for SAP Cloud for Customer

从 SAP Cloud for Customer 复制数据时,以下映射用于从 SAP Cloud for Customer 数据类型映射到 Azure 数据工厂临时数据类型。When copying data from SAP Cloud for Customer, the following mappings are used from SAP Cloud for Customer data types to Azure Data Factory interim data types. 若要了解复制活动如何将源架构和数据类型映射到接收器,请参阅架构和数据类型映射See Schema and data type mappings to learn about how copy activity maps the source schema and data type to the sink.

SAP C4C OData 数据类型SAP C4C OData Data Type 数据工厂临时数据类型Data factory interim data type
Edm.BinaryEdm.Binary Byte[]Byte[] 
Edm.BooleanEdm.Boolean BoolBool
Edm.ByteEdm.Byte Byte[]Byte[] 
Edm.DateTimeEdm.DateTime DateTimeDateTime
Edm.DecimalEdm.Decimal DecimalDecimal
Edm.DoubleEdm.Double DoubleDouble
Edm.SingleEdm.Single SingleSingle
Edm.GuidEdm.Guid GuidGuid 
Edm.Int16Edm.Int16 Int16Int16
Edm.Int32Edm.Int32 Int32Int32
Edm.Int64Edm.Int64 Int64Int64
Edm.SByteEdm.SByte Int16Int16
Edm.StringEdm.String StringString
Edm.TimeEdm.Time TimeSpanTimeSpan
Edm.DateTimeOffsetEdm.DateTimeOffset DateTimeOffsetDateTimeOffset

Lookup 活动属性Lookup activity properties

若要了解有关属性的详细信息,请查看 Lookup 活动To learn details about the properties, check Lookup activity.

后续步骤Next steps

有关 Azure 数据工厂中复制活动支持作为源和接收器的数据存储的列表,请参阅支持的数据存储For a list of data stores supported as sources and sinks by the copy activity in Azure Data Factory, see supported data stores.