使用 Azure 数据工厂从/向 Dynamics 365 (Common Data Service) 或 Dynamics CRM 复制数据Copy data from and to Dynamics 365 (Common Data Service) or Dynamics CRM by using Azure Data Factory

适用于:是 Azure 数据工厂是 Azure Synapse Analytics(预览版)APPLIES TO: yesAzure Data Factory yesAzure Synapse Analytics (Preview)

本文概述如何使用 Azure 数据工厂中的复制活动从/向 Microsoft Dynamics 365 或 Microsoft Dynamics CRM 复制数据。This article outlines how to use Copy Activity in Azure Data Factory to copy data from and to Microsoft Dynamics 365 or Microsoft Dynamics CRM. 本文是根据总体概述复制活动的复制活动概述一文编写的。It builds on the Copy Activity overview article that presents a general overview of Copy Activity.

支持的功能Supported capabilities

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

可以将数据从 Dynamics 365 (Common Data Service) 或 Dynamics CRM 复制到任何支持的接收器数据存储。You can copy data from Dynamics 365 (Common Data Service) or Dynamics CRM to any supported sink data store. 还可以将数据从任何支持的源数据存储复制到 Dynamics 365 (Common Data Service) 或 Dynamics CRM。You also can copy data from any supported source data store to Dynamics 365 (Common Data Service) or Dynamics CRM. 有关复制活动支持作为源或接收器的数据存储列表,请参阅支持的数据存储表。For a list of data stores supported as sources or sinks by the copy activity, see the Supported data stores table.

此 Dynamics 连接器支持联机或本地的 Dynamics 版本 7.x 到 9.x。This Dynamics connector supports Dynamics version 7.x to 9.x for both online or on-premises. 更具体地说,More specifically,

  • 版本 7.x 映射到 Dynamics CRM 2015Version 7.x maps to Dynamics CRM 2015
  • 版本 8.x 映射到 Dynamics CRM 2016 和 Dynamics 365 的早期版本Version 8.x maps to Dynamics CRM 2016 and the early version of Dynamics 365
  • 版本 9.x 映射到 Dynamics 365 的更高版本Version 9.x maps to the later version of Dynamics 365

请参阅下表,了解各种 Dynamics 版本/产品支持的身份验证类型和配置。Refer to the following table on the supported authentication types and configurations for respective Dynamics versions/products. IFD 是“Internet Facing Deployment”(面向 Internet 的部署)的缩写。(IFD is short for internet-facing deployment.)

Dynamics 版本Dynamics versions 身份验证类型Authentication types 链接的服务示例Linked service samples
Common Data ServiceCommon Data Service
Dynamics 365 联机Dynamics 365 online
Dynamics CRM OnlineDynamics CRM Online
AAD 服务主体AAD service principal
Office365Office365
Dynamics Online + AAD 服务主体或 Office365 身份验证Dynamics online + AAD service principal or Office365 auth
带有 IFD 的本地 Dynamics 365Dynamics 365 on-premises with IFD
带有 IFD 的本地 Dynamics CRM 2016Dynamics CRM 2016 on-premises with IFD
带有 IFD 的本地 Dynamics CRM 2015Dynamics CRM 2015 on-premises with IFD
IFDIFD 带有 IFD 的本地 Dynamics + IFD 身份验证Dynamics on-premises with IFD + IFD auth

具体而言,对于 Dynamics 365,支持以下应用程序类型:For Dynamics 365 specifically, the following application types are supported:

  • Dynamics 365 for SalesDynamics 365 for Sales
  • Dynamics 365 for Customer ServiceDynamics 365 for Customer Service
  • Dynamics 365 for Field ServiceDynamics 365 for Field Service
  • Dynamics 365 for Project Service AutomationDynamics 365 for Project Service Automation
  • Dynamics 365 for MarketingDynamics 365 for Marketing

此连接器不支持其他应用程序类型,如 Finance and Operations、Talent 等。Other application types e.g. Finance and Operations, Talent, etc. are not supported by this connector.

此 Dynamics 连接器基于 Dynamics XRM 工具构建。This Dynamics connector is built on top of Dynamics XRM tooling.

提示

若要从 Dynamics 365 Finance and Operations 复制数据,可以使用 Dynamics AX 连接器To copy data from Dynamics 365 Finance and Operations, you can use the Dynamics AX connector.

先决条件Prerequisites

若要将此连接器与 AAD 服务主体身份验证配合使用,需要在 Common Data Service 或 Dynamics 中设置服务器到服务器 (S2S) 身份验证。To use this connector with AAD service principal authentication, you need to set up Server-to-Server (S2S) authentication in Common Data Service or Dynamics. 请参阅此文了解详细步骤。Refer to this article on detailed steps.

入门Get started

若要使用管道执行复制活动,可以使用以下工具或 SDK 之一:To perform the Copy activity with a pipeline, you can use one of the following tools or SDKs:

以下部分提供了有关各属性的详细信息,这些属性用于定义特定于 Dynamics 的数据工厂实体。The following sections provide details about properties that are used to define Data Factory entities specific to Dynamics.

链接服务属性Linked service properties

Dynamics 链接服务支持以下属性。The following properties are supported for the Dynamics linked service.

Dynamics 365 和 Dynamics CRM OnlineDynamics 365 and Dynamics CRM Online

属性Property 说明Description 必须Required
typetype 类型属性必须设置为 DynamicsDynamicsCrmCommonDataServiceForAppsThe type property must be set to Dynamics, DynamicsCrm, or CommonDataServiceForApps. Yes
deploymentTypedeploymentType Dynamics 实例的部署类型。The deployment type of the Dynamics instance. Dynamics Online 必须为 "Online"It must be "Online" for Dynamics online. Yes
serviceUriserviceUri 你的 Dynamics 实例的服务 URL,例如 https://adfdynamics.crm.dynamics.comThe service URL of your Dynamics instance, e.g. https://adfdynamics.crm.dynamics.com. Yes
authenticationTypeauthenticationType 要连接到 Dynamics 服务器的身份验证类型。The authentication type to connect to a Dynamics server. 允许值包括:AADServicePrincipal"Office365"Allowed values are: AADServicePrincipal or "Office365". Yes
servicePrincipalIdservicePrincipalId 指定 Azure Active Directory 应用程序的客户端 ID。Specify the Azure Active Directory application's client ID. 在使用 AADServicePrincipal 身份验证时为“是”Yes when using AADServicePrincipal authentication
servicePrincipalCredentialTypeservicePrincipalCredentialType 指定要用于服务主体身份验证的凭据类型。Specify the credential type to use for service principal authentication. 允许值包括:ServicePrincipalKeyServicePrincipalCertAllowed values are: ServicePrincipalKey or ServicePrincipalCert. 在使用 AADServicePrincipal 身份验证时为“是”Yes when using AADServicePrincipal authentication
servicePrincipalCredentialservicePrincipalCredential 指定服务主体凭据。Specify the service principal credential.
使用 ServicePrincipalKey 作为凭据类型时,servicePrincipalCredential 可以是字符串(ADF 会在链接服务部署的基础上对其加密),也可以是对 AKV 中机密的引用。When using ServicePrincipalKey as credential type, servicePrincipalCredential can be a string (ADF will encrypt it upon linked service deployment) or a reference to a secret in AKV.
使用 ServicePrincipalCert 作为凭据时,servicePrincipalCredential 应该是对 AKV 中证书的引用。When using ServicePrincipalCert as credential, servicePrincipalCredential should be a reference to a certificate in AKV.
在使用 AADServicePrincipal 身份验证时为“是”Yes when using AADServicePrincipal authentication
usernameusername 指定用于连接到 Dynamics 的用户名。Specify the user name to connect to Dynamics. 在使用 Office365 身份验证时为“是”Yes when using Office365 authentication
passwordpassword 指定为 username 指定的用户帐户的密码。Specify the password for the user account you specified for 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. 在使用 Office365 身份验证时为“是”Yes when using Office365 authentication
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 for source, Yes for sink if the source linked service doesn't have an integration runtime

备注

Dynamics 连接器使用可选的“organizationName”属性来标识 Dynamics CRM/365 Online 实例。The Dynamics connector used to use optional "organizationName" property to identify your Dynamics CRM/365 Online instance. 虽然它保持正常工作,但建议改为指定新的“serviceUri”属性来获得更好的实例发现性能。While it keeps working, you are suggested to specify the new "serviceUri" property instead to gain better performance for instance discovery.

示例:使用 AAD 服务主体 + 密钥身份验证的 Dynamics OnlineExample: Dynamics online using AAD service principal + key authentication

{  
    "name": "DynamicsLinkedService",  
    "properties": {  
        "type": "Dynamics",  
        "typeProperties": {  
            "deploymentType": "Online",  
            "serviceUri": "https://adfdynamics.crm.dynamics.com",  
            "authenticationType": "AADServicePrincipal",  
            "servicePrincipalId": "<service principal id>",  
            "servicePrincipalCredentialType": "ServicePrincipalKey",  
            "servicePrincipalCredential": "<service principal key>"
        },  
        "connectVia": {  
            "referenceName": "<name of Integration Runtime>",  
            "type": "IntegrationRuntimeReference"  
        }  
    }  
}  

示例:使用 AAD 服务主体 + 证书身份验证的 Dynamics OnlineExample: Dynamics online using AAD service principal + certificate authentication

{ 
    "name": "DynamicsLinkedService", 
    "properties": { 
        "type": "Dynamics", 
        "typeProperties": { 
            "deploymentType": "Online", 
            "serviceUri": "https://adfdynamics.crm.dynamics.com", 
            "authenticationType": "AADServicePrincipal", 
            "servicePrincipalId": "<service principal id>", 
            "servicePrincipalCredentialType": "ServicePrincipalCert", 
            "servicePrincipalCredential": { 
                "type": "AzureKeyVaultSecret", 
                "store": { 
                    "referenceName": "<AKV reference>", 
                    "type": "LinkedServiceReference" 
                }, 
                "secretName": "<certificate name in AKV>" 
            } 
        }, 
        "connectVia": { 
            "referenceName": "<name of Integration Runtime>", 
            "type": "IntegrationRuntimeReference" 
        } 
    } 
} 

示例:使用 Office365 身份验证的 Dynamics 联机Example: Dynamics online using Office365 authentication

{
    "name": "DynamicsLinkedService",
    "properties": {
        "type": "Dynamics",
        "typeProperties": {
            "deploymentType": "Online",
            "serviceUri": "https://adfdynamics.crm.dynamics.com",
            "authenticationType": "Office365",
            "username": "test@contoso.partner.onmschina.cn",
            "password": {
                "type": "SecureString",
                "value": "<password>"
            }
        },
        "connectVia": {
            "referenceName": "<name of Integration Runtime>",
            "type": "IntegrationRuntimeReference"
        }
    }
}

带有 IFD 的本地 Dynamics 365 和 Dynamics CRMDynamics 365 and Dynamics CRM on-premises with IFD

与 Dynamics 联机进行对比的其他属性是“hostName”和“port”。Additional properties that compare to Dynamics online are "hostName" and "port".

属性Property 说明Description 必须Required
typetype 类型属性必须设置为 DynamicsDynamicsCrmCommonDataServiceForAppsThe type property must be set to Dynamics, DynamicsCrm, or CommonDataServiceForApps. Yes
deploymentTypedeploymentType Dynamics 实例的部署类型。The deployment type of the Dynamics instance. 带有 IFD 的本地 Dynamics 必须为 "OnPremisesWithIfd"It must be "OnPremisesWithIfd" for Dynamics on-premises with IFD. Yes
hostNamehostName 本地 Dynamics 服务器的主机名称。The host name of the on-premises Dynamics server. Yes
portport 本地 Dynamics 服务器的端口。The port of the on-premises Dynamics server. 否,默认端口为 443No, default is 443
organizationNameorganizationName Dynamics 实例的组织名称。The organization name of the Dynamics instance. Yes
authenticationTypeauthenticationType 要连接到 Dynamics 服务器的身份验证类型。The authentication type to connect to the Dynamics server. 为带有 IFD 的本地 Dynamics 指定“Ifd”Specify "Ifd" for Dynamics on-premises with IFD. Yes
usernameusername 指定用于连接到 Dynamics 的用户名。Specify the user name to connect to Dynamics. Yes
passwordpassword 指定为 username 指定的用户帐户的密码。Specify the password for the user account you specified for username. 可选择将此字段标记为 SecureString,将其安全地存储在 ADF 中,或在 Azure Key Vault 中存储密码,并允许复制活动在执行数据复制时从此处拉取(请参阅在 Key Vault 中存储凭据了解详细信息)。You can choose to mark this field as a SecureString to store it securely in ADF, or store password in Azure Key Vault and let the copy activity pull from there when performing data copy - learn more from Store credentials in 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

示例:带有 IFD、使用 IFD 身份验证的本地 DynamicsExample: Dynamics on-premises with IFD using IFD authentication

{
    "name": "DynamicsLinkedService",
    "properties": {
        "type": "Dynamics",
        "description": "Dynamics on-premises with IFD linked service using IFD authentication",
        "typeProperties": {
            "deploymentType": "OnPremisesWithIFD",
            "hostName": "contosodynamicsserver.contoso.com",
            "port": 443,
            "organizationName": "admsDynamicsTest",
            "authenticationType": "Ifd",
            "username": "test@contoso.partner.onmschina.cn",
            "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. 本部分提供 Dynamics 数据集支持的属性列表。This section provides a list of properties supported by Dynamics dataset.

支持使用以下属性从/向 Dynamics 复制数据。To copy data from and to Dynamics, the following properties are supported.

属性Property 说明Description 必须Required
typetype 数据集的类型属性必须设置为 DynamicsEntityDynamicsCrmEntityCommonDataServiceForAppsEntityThe type property of the dataset must be set to DynamicsEntity, DynamicsCrmEntity, or CommonDataServiceForAppsEntity. Yes
entityNameentityName 要检索的实体的逻辑名称。The logical name of the entity to retrieve. 源为“No”(如果指定了活动源中的“query”),接收器为“Yes”No for source (if "query" in the activity source is specified), Yes for sink

示例:Example:

{
    "name": "DynamicsDataset",
    "properties": {
        "type": "DynamicsEntity",
        "schema": [],
        "typeProperties": {
            "entityName": "account"
        },
        "linkedServiceName": {
            "referenceName": "<Dynamics linked service name>",
            "type": "linkedservicereference"
        }
    }
}

复制活动属性Copy activity properties

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

将 Dynamics 用作源类型Dynamics as a source type

若要从 Dynamics 复制数据,复制活动的 source 节需要支持以下属性。To copy data from Dynamics, the following properties are supported in the copy activity source section.

属性Property 说明Description 必须Required
typetype 复制活动源的 type 属性必须设置为 DynamicsSourceDynamicsCrmSourceCommonDataServiceForAppsSourceThe type property of the copy activity source must be set to DynamicsSource, DynamicsCrmSource, or CommonDataServiceForAppsSource. Yes
查询query FetchXML 是在 Dynamics(联机和本地)中使用的专属查询语言。FetchXML is a proprietary query language that is used in Dynamics (online and on-premises). 请参阅以下示例。See the following example. 若要了解详细信息,请参阅使用 FetchXML 生成查询To learn more, see Build queries with FetchXML. 否(如果指定了数据集中的“entityName”)No (if "entityName" in the dataset is specified)

备注

即使在 FetchXML 查询中配置的列投影不包含 PK 列,也将始终复制该列。The PK column will always be copied out even if the column projection you configure in the FetchXML query doesn't contain it.

重要

  • 从 Dynamics 复制数据时,从 Dynamics 到接收器的显式列映射为可选,但若要确保确定性的复制结果,则强烈建议使用它。When you copy data from Dynamics, explicit column mapping from Dynamics to sink is optional but highly recommanded to ensure a deterministic copy result.
  • 在创作 UI 中导入架构时,ADF 通过对 Dynamics 查询结果中的前几行进行采样来初始化源列列表,将省略顶部行中不含任何值的列。When importing schema in authoring UI, ADF infers the schema by sampling the top rows from the Dynamics query result to initialize the source column list, in which case columns with no values in top rows will be omitted. 如果没有明确的映射,则相同的行为也适用于复制执行。The same behavior applies to copy executions if there is no explicit mapping. 可以查看列并将更多列添加到映射,这将在副本运行时起作用。You can review and add more columns into the mapping, which will be honored during copy runtime.

示例:Example:

"activities":[
    {
        "name": "CopyFromDynamics",
        "type": "Copy",
        "inputs": [
            {
                "referenceName": "<Dynamics input dataset>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<output dataset>",
                "type": "DatasetReference"
            }
        ],
        "typeProperties": {
            "source": {
                "type": "DynamicsSource",
                "query": "<FetchXML Query>"
            },
            "sink": {
                "type": "<sink type>"
            }
        }
    }
]

示例 FetchXML 查询Sample FetchXML query

<fetch>
  <entity name="account">
    <attribute name="accountid" />
    <attribute name="name" />
    <attribute name="marketingonly" />
    <attribute name="modifiedon" />
    <order attribute="modifiedon" descending="false" />
    <filter type="and">
      <condition attribute ="modifiedon" operator="between">
        <value>2017-03-10 18:40:00z</value>
        <value>2017-03-12 20:40:00z</value>
      </condition>
    </filter>
  </entity>
</fetch>

将 Dynamics 用作接收器类型Dynamics as a sink type

若要将数据复制到 Dynamics,复制活动的 sink 节需要支持以下属性。To copy data to Dynamics, the following properties are supported in the copy activity sink section.

属性Property 说明Description 必须Required
typetype 复制活动接收器的 type 属性必须设置为 DynamicsSinkDynamicsCrmSinkCommonDataServiceForAppsSinkThe type property of the copy activity sink must be set to DynamicsSink, DynamicsCrmSink, or CommonDataServiceForAppsSink. Yes
writeBehaviorwriteBehavior 操作的写入行为。The write behavior of the operation.
允许的值为 "Upsert"Allowed value is "Upsert".
Yes
alternateKeyNamealternateKeyName 指定在实体上定义的可选密钥名称以执行“更新插入”。Specify the alternate key name defined on your entity to perform "Upsert". No
writeBatchSizewriteBatchSize 每批中写入到 Dynamics 的数据行计数。The row count of data written to Dynamics in each batch. 否(默认值为 10)No (default is 10)
ignoreNullValuesignoreNullValues 指示是否忽略 null 值从输入数据(键字段除外)期间写入操作。Indicates whether to ignore null values from input data (except key fields) during a write operation.
允许的值为 truefalseAllowed values are true and false.
- True:执行更新插入/更新操作时,保持目标对象中的数据不变。- True: Leave the data in the destination object unchanged when you do an upsert/update operation. 插入在执行插入操作时定义的默认值。Insert a defined default value when you do an insert operation.
- False:执行更新插入/更新操作时,将目标对象中的数据更新为 NULL。- False: Update the data in the destination object to NULL when you do an upsert/update operation. 执行插入操作时插入 NULL 值。Insert a NULL value when you do an insert operation.
否(默认值为 false)No (default is false)

备注

接收器“writeBatchSize”和 Dynamics 接收器的复制活动“parallelCopies” 的默认值都是 10。The default value of the sink "writeBatchSize" and the copy activity "parallelCopies" for the Dynamics sink are both 10. 因此,会将 100 条记录同时提交到 Dynamics。Therefore, 100 records are submitted to Dynamics concurrently.

对于 Dynamics 365(联机版),存在每个组织进行 2 次并发批量调用的限制。For Dynamics 365 online, there is a limit of 2 concurrent batch calls per organization. 如果超出此限制,则会在执行第一个请求之前引发“服务器忙”错误。If that limit is exceeded, a "Server Busy" fault is thrown before the first request is ever executed. 保持“writeBatchSize”小于或等于 10 可避免这种并发调用的限制。Keeping "writeBatchSize" less or equal to 10 would avoid such throttling of concurrent calls.

“writeBatchSize”和“parallelCopies”的最佳组合取决于实体的架构,例如列数、行大小、与这些调用挂钩的插件/工作流/工作流活动的数量等。10 writeBatchSize * 10 parallelCopies 的默认设置是基于 Dynamics 服务提供的建议设置,该服务可用于大多数 Dynamics 实体,但可能无法获得最佳性能。The optimal combination of "writeBatchSize" and "parallelCopies" depends on the schema of your entity e.g. number of columns, row size, number of plugins/workflows/workflow activities hooked up to those calls, etc. The default setting of 10 writeBatchSize * 10 parallelCopies is the recommendation according to Dynamics service, which would work for most Dynamics entities though may not be best performance. 你可以通过在复制活动设置中调整组合来调整性能。You can tune the performance by adjusting the combination in your copy activity settings.

示例:Example:

"activities":[
    {
        "name": "CopyToDynamics",
        "type": "Copy",
        "inputs": [
            {
                "referenceName": "<input dataset>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<Dynamics output dataset>",
                "type": "DatasetReference"
            }
        ],
        "typeProperties": {
            "source": {
                "type": "<source type>"
            },
            "sink": {
                "type": "DynamicsSink",
                "writeBehavior": "Upsert",
                "writeBatchSize": 10,
                "ignoreNullValues": true
            }
        }
    }
]

Dynamics 的数据类型映射Data type mapping for Dynamics

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

使用以下映射表,根据源 Dynamics 数据类型在数据集结构中配置相应的数据工厂数据类型。Configure the corresponding Data Factory data type in a dataset structure based on your source Dynamics data type by using the following mapping table.

Dynamics 数据类型Dynamics data type 数据工厂临时数据类型Data Factory interim data type 支持用作源Supported as source 支持用作接收器Supported as sink
AttributeTypeCode.BigIntAttributeTypeCode.BigInt LongLong
AttributeTypeCode.BooleanAttributeTypeCode.Boolean 布尔Boolean
AttributeType.CustomerAttributeType.Customer GUIDGUID ✓(请参阅指南✓ (see guidance)
AttributeType.DateTimeAttributeType.DateTime datetimeDatetime
AttributeType.DecimalAttributeType.Decimal 小数Decimal
AttributeType.DoubleAttributeType.Double DoubleDouble
AttributeType.EntityNameAttributeType.EntityName StringString
AttributeType.IntegerAttributeType.Integer Int32Int32
AttributeType.LookupAttributeType.Lookup GUIDGUID ✓(请参阅指南✓ (see guidance)
AttributeType.ManagedPropertyAttributeType.ManagedProperty 布尔Boolean
AttributeType.MemoAttributeType.Memo StringString
AttributeType.MoneyAttributeType.Money 小数Decimal
AttributeType.OwnerAttributeType.Owner GUIDGUID ✓(请参阅指南✓ (see guidance)
AttributeType.PicklistAttributeType.Picklist Int32Int32
AttributeType.UniqueidentifierAttributeType.Uniqueidentifier GUIDGUID
AttributeType.StringAttributeType.String StringString
AttributeType.StateAttributeType.State Int32Int32
AttributeType.StatusAttributeType.Status Int32Int32

备注

Dynamics 数据类型 AttributeType.CalendarRules、AttributeType.MultiSelectPicklist 和 AttributeType.PartyList 不受支持。The Dynamics data types AttributeType.CalendarRules, AttributeType.MultiSelectPicklist and AttributeType.PartyList aren't supported.

将数据写入查找字段Writing data to lookup field

若要将数据写入包含多个目标(例如 Customer 和 Owner)的查找字段,请遵循以下指导和示例:To write data into lookup field with multiple targets, e.g. Customer and Owner, follow this guidance and example:

  1. 使源同时包含字段值和相应的目标实体名称。Make your source containing both the field value and the corresponding target entity name.

    • 如果所有记录都映射到相同的目标实体,请确保源数据包含一个可存储目标实体名称的列,或添加复制活动源中的其他列以定义目标实体。If all the records map to the same target entity, make sure either your source data has a column which stores the target entity name, or to add an additional column in copy activity source to define the target entity.
    • 如果不同的记录映射到不同的目标实体,请确保源数据包含一个可存储相应目标实体名称的列。If different records map to different target entity, make sure your source data has a column which stores the corresponding target entity name.
  2. 将值列和实体引用列都从源映射到接收器。Map both the value and entity reference columns from source to sink. 实体引用列将需要通过特殊命名模式 {lookup_field_name}@EntityReference 映射到虚拟列。The entity reference column need to be mapped to a virtual column with a special naming pattern{lookup_field_name}@EntityReference. 它并非实际存在于 Dynamics 中,只是用于指示这是给定多目标查找字段的元数据列。It does not actually exist in Dynamics, but it's used to indicate this is the metadata column of the given multi-target lookup field.

例如,源包含两列:For example, the source has two columns:

  • GUID类型的 CustomerField 列,它是 Dynamics 中目标实体的主键值。CustomerField column of type GUID, which is the primary key value of the target entity in Dynamics.
  • String 类型的 Target 列,它是目标实体的逻辑名称。Target column of type String, which is the logical name of the target entity.

你希望将此类数据复制到 Customer 类型的接收器 Dynamics 实体字段 CustomerFieldAnd you want to copy such data to sink Dynamics entity field CustomerField of type Customer.

在复制活动列映射中,按如下所示映射这两列:In copy activity column mapping, map the two columns as follows:

  • CustomerField -> CustomerField:这是标准字段映射。CustomerField -> CustomerField: this is the normal field mapping.
  • Target -> CustomerField@EntityReference:接收器列是表示实体引用的虚拟列。Target -> CustomerField@EntityReference: the sink column is a virtual column representing the entity reference. 请在映射中输入此类字段名称,因为不可通过导入架构来显示它。Input such field name in mapping, as it won't show up by importing schemas.

动态查找字段列映射

如果所有源记录都映射到相同的目标实体,并且源数据不包含目标实体名称,则可使用下面的快捷方式:在复制活动源中,添加其他列。If all your source records map to the same target entity and your source data doesn't contains the target entity name, here is a shortcut: in copy activity source, add an additional column. 可以按照模式 {lookup_field_name}@EntityReference 指定名称,并将值指定为目标实体名称。在这种情况下,显式列映射将变为可选项,因为复制活动默认按名称来映射列。You can specify the name following the pattern {lookup_field_name}@EntityReference and value as the target entity name, in which case explicit column mapping becomes optional because copy activity by default maps columns by name.

Dynamics 查找字段添加实体引用

查找活动属性Lookup activity properties

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

后续步骤Next steps

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