使用 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(预览版)

本文概述了如何使用 Azure 数据工厂中的复制活动从/向 Microsoft Dynamics 365 和 Microsoft Dynamics CRM 复制数据。This article outlines how to use a copy activity in Azure Data Factory to copy data from and to Microsoft Dynamics 365 and Microsoft Dynamics CRM. 它基于复制活动概述一文,该文概述了复制活动。It builds on the copy activity overview article that presents a general overview of a 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 that a copy activity supports as sources and sinks, see the Supported data stores table.

此 Dynamics 连接器支持联机的和本地的 Dynamics 版本 7-9。This Dynamics connector supports Dynamics versions 7 through 9 for both online and on-premises. 更具体地说:More specifically:

  • 版本 7 映射到 Dynamics CRM 2015。Version 7 maps to Dynamics CRM 2015.
  • 版本 8 映射到 Dynamics CRM 2016 和早期版 Dynamics 365。Version 8 maps to Dynamics CRM 2016 and the early version of Dynamics 365.
  • 版本 9 映射到较新版 Dynamics 365。Version 9 maps to the later version of Dynamics 365.

请参阅下表,了解各种 Dynamics 版本和产品支持的身份验证类型和配置。Refer to the following table of supported authentication types and configurations for Dynamics versions and products.

Dynamics 版本Dynamics versions 身份验证类型Authentication types 链接的服务示例Linked service samples
Common Data ServiceCommon Data Service

Dynamics 365 联机Dynamics 365 online

Dynamics CRM 联机Dynamics CRM online
Azure Active Directory (Azure AD) 服务主体Azure Active Directory (Azure AD) service principal

Office 365Office 365
联机 Dynamics 和 Azure AD 服务主体或 Office 365 身份验证Dynamics online and Azure AD service-principal or Office 365 authentication
本地 Dynamics 365,具有面向 Internet 的部署 (IFD)Dynamics 365 on-premises with internet-facing deployment (IFD)

带有 IFD 的本地 Dynamics CRM 2016Dynamics CRM 2016 on-premises with IFD

带有 IFD 的本地 Dynamics CRM 2015Dynamics CRM 2015 on-premises with IFD
IFDIFD 带有 IFD 和 IFD 身份验证的本地 DynamicsDynamics on-premises with IFD and IFD authentication

具体而言,对于 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

此连接器不支持其他应用程序类型,如“财务”、“运营”和“人才”。This connector doesn't support other application types like Finance, Operations, and Talent.

此 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

若要将此连接器与 Azure AD 服务主体身份验证配合使用,必须在 Common Data Service 或 Dynamics 中设置服务器到服务器 (S2S) 身份验证。To use this connector with Azure AD service-principal authentication, you must set up server-to-server (S2S) authentication in Common Data Service or Dynamics. 请参阅此文,了解详细步骤。Refer to this article for 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 CRMDynamics 365 and Dynamics CRM online

属性Property 说明Description 必需Required
typetype type 属性必须设置为“Dynamics”、“DynamicsCrm”或“CommonDataServiceForApps”。The type property must be set to "Dynamics", "DynamicsCrm", or "CommonDataServiceForApps". Yes
deploymentTypedeploymentType Dynamics 实例的部署类型。The deployment type of the Dynamics instance. 对于联机 Dynamics,此值必须为“Online”。The value must be "Online" for Dynamics online. Yes
serviceUriserviceUri Dynamics 实例的服务 URL,与从浏览器访问的 URL 相同。The service URL of your Dynamics instance, the same one you access from browser. 例如“https://<organization-name>.crm[x].dynamics.com”。An example is "https://<organization-name>.crm[x].dynamics.com". Yes
authenticationTypeauthenticationType 要连接到 Dynamics 服务器的身份验证类型。The authentication type to connect to a Dynamics server. 有效值为“AADServicePrincipal”和“Office365”。Valid values are "AADServicePrincipal" and "Office365". Yes
servicePrincipalIdservicePrincipalId Azure AD 应用程序的客户端 ID。The client ID of the Azure AD application. 当身份验证为“AADServicePrincipal”时,此项为必需的Yes when authentication is "AADServicePrincipal"
servicePrincipalCredentialTypeservicePrincipalCredentialType 要用于服务主体身份验证的凭据类型。The credential type to use for service-principal authentication. 有效值为“ServicePrincipalKey”和“ServicePrincipalCert”。Valid values are "ServicePrincipalKey" and "ServicePrincipalCert". 当身份验证为“AADServicePrincipal”时,此项为必需的Yes when authentication is "AADServicePrincipal"
servicePrincipalCredentialservicePrincipalCredential 服务主体凭据。The service-principal credential.

使用“ServicePrincipalKey”作为凭据类型时,servicePrincipalCredential 可以是 Azure 数据工厂在部署链接服务时加密的字符串。When you use "ServicePrincipalKey" as the credential type, servicePrincipalCredential can be a string that Azure Data Factory encrypts upon linked service deployment. 它也可以是对 Azure Key Vault 中机密的引用。Or it can be a reference to a secret in Azure Key Vault.

使用“ServicePrincipalCert”作为凭据时,servicePrincipalCredential 必须是对 Azure Key Vault 中证书的引用。When you use "ServicePrincipalCert" as the credential, servicePrincipalCredential must be a reference to a certificate in Azure Key Vault.
当身份验证为“AADServicePrincipal”时,此项为必需的Yes when authentication is "AADServicePrincipal"
usernameusername 用于连接到 Dynamics 的用户名。The username to connect to Dynamics. 当身份验证为“Office365”时,此项为必需的Yes when authentication is "Office365"
passwordpassword 作为用户名指定的用户帐户的密码。The password for the user account you specified as the username. 将此字段标记为“SecureString”以将其安全地存储在数据工厂中,或引用存储在 Azure Key Vault 中的机密Mark this field with "SecureString" to store it securely in Data Factory, or reference a secret stored in Azure Key Vault. 当身份验证为“Office365”时,此项为必需的Yes when authentication is "Office365"
connectViaconnectVia 用于连接到数据存储的集成运行时The integration runtime to be used to connect to the data store. 如果未指定任何值,则此属性使用默认的 Azure 集成运行时。If no value is specified, the property uses the default Azure integration runtime. 对于源非必需,对于接收器为必需的(如果源链接服务没有集成运行时)No for source, and yes for sink if the source linked service doesn't have an integration runtime

备注

Dynamics 连接器以前使用可选的 organizationName 属性来标识 Dynamics CRM 或 Dynamics 365 联机实例。The Dynamics connector formerly used the optional organizationName property to identify your Dynamics CRM or Dynamics 365 online instance. 虽然该属性仍然有效,但建议你改为指定新的 serviceUri 属性以实现更好的实例发现性能。While that property still works, we suggest you specify the new serviceUri property instead to gain better performance for instance discovery.

示例:使用 Azure AD 服务主体和密钥身份验证的联机 DynamicsExample: Dynamics online using Azure AD service-principal and key authentication

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

示例:使用 Azure AD 服务主体和证书身份验证的联机 DynamicsExample: Dynamics online using Azure AD service-principal and certificate authentication

{ 
    "name": "DynamicsLinkedService", 
    "properties": { 
        "type": "Dynamics", 
        "typeProperties": { 
            "deploymentType": "Online", 
            "serviceUri": "https://<organization-name>.crm[x].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" 
        } 
    } 
} 

示例:使用 Office 365 身份验证的联机 DynamicsExample: Dynamics online using Office 365 authentication

{
    "name": "DynamicsLinkedService",
    "properties": {
        "type": "Dynamics",
        "typeProperties": {
            "deploymentType": "Online",
            "serviceUri": "https://<organization-name>.crm[x].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 进行对比的其他属性是 hostNameportAdditional properties that compare to Dynamics online are hostName and port .

属性Property 说明Description 必需Required
typetype type 属性必须设置为“Dynamics”、“DynamicsCrm”或“CommonDataServiceForApps”。The type property must be set to "Dynamics", "DynamicsCrm", or "CommonDataServiceForApps". 是的。Yes.
deploymentTypedeploymentType Dynamics 实例的部署类型。The deployment type of the Dynamics instance. 对于带有 IFD 的本地 Dynamics,此值必须为“OnPremisesWithIfd”。The value 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. 否。No. 默认值为 443。The default value 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 的用户名。The username to connect to Dynamics. 是的。Yes.
passwordpassword 指定为用户名的用户帐户的密码。The password for the user account you specified for the username. 可以将此字段标记为“SecureString”,以便安全地将其存储在数据工厂中。You can mark this field with "SecureString" to store it securely in Data Factory. 也可将密码存储在 Key Vault 中,让复制活动在进行数据复制时从其中拉取密码。Or you can store a password in Key Vault and let the copy activity pull from there when it does data copy. 在 Key Vault 中存储凭据中了解详细信息。Learn more from Store credentials in Key Vault. 是的。Yes.
connectViaconnectVia 用于连接到数据存储的集成运行时The integration runtime to be used to connect to the data store. 如果未指定任何值,则此属性使用默认的 Azure 集成运行时。If no value is specified, the property uses the default Azure integration runtime. 对于源非必需,对于接收器为必需的。No for source and 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 数据集的 type 属性必须设置为“DynamicsEntity”、“DynamicsCrmEntity”或“CommonDataServiceForAppsEntity”。The type property of the dataset must be set to "DynamicsEntity", "DynamicsCrmEntity", or "CommonDataServiceForAppsEntity". Yes
entityNameentityName 要检索的实体的逻辑名称。The logical name of the entity to retrieve. 对于源非必需(如果将活动源指定为“query”),对于接收器为必需的No for source if the activity source is specified as "query" and 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 copy activity source section supports the following properties:

属性Property 说明Description 必需Required
typetype 复制活动源的 type 属性必须设置为“DynamicsSource”、“DynamicsCrmSource”或“CommonDataServiceForAppsSource”。The type property of the copy activity source must be set to "DynamicsSource", "DynamicsCrmSource", or "CommonDataServiceForAppsSource". Yes
queryquery 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. 否(如果指定了数据集中的 entityNameNo 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 we highly recommend the mapping to ensure a deterministic copy result.
  • 数据工厂在创作 UI 中导入架构时,会对架构进行推断。When Data Factory imports a schema in the authoring UI, it infers the schema. 其方法是:对 Dynamics 查询结果中的前几行进行采样来初始化源列列表。It does so by sampling the top rows from the Dynamics query result to initialize the source column list. 在这种情况下,将省略在前几行中不含任何值的列。In that case, columns with no values in the top rows are 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 are 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 copy activity sink section supports the following properties:

属性Property 说明Description 必需Required
typetype 复制活动接收器的 type 属性必须设置为“DynamicsSink”、“DynamicsCrmSink”或“CommonDataServiceForAppsSink”。The type property of the copy activity sink must be set to "DynamicsSink", "DynamicsCrmSink", or "CommonDataServiceForAppsSink". 是的。Yes.
writeBehaviorwriteBehavior 操作的写入行为。The write behavior of the operation. 值必须是“Upsert”。The value must be "Upsert". Yes
alternateKeyNamealternateKeyName 在实体上定义的用于执行更新插入的备用密钥名称。The alternate key name defined on your entity to do an upsert. 否。No.
writeBatchSizewriteBatchSize 每批中写入到 Dynamics 的数据行计数。The row count of data written to Dynamics in each batch. 否。No. 默认值为 10。The default value is 10.
ignoreNullValuesignoreNullValues 在执行写入操作期间是否忽略输入数据中的 NULL 值(键字段除外)。Whether to ignore null values from input data other than key fields during a write operation.

有效值为 TRUEFALSEValid values are TRUE and FALSE :
  • TRUE :执行更新插入或更新操作时,保持目标对象中的数据不变。TRUE : Leave the data in the destination object unchanged when you do an upsert or update operation. 插入在执行插入操作时定义的默认值。Insert a defined default value when you do an insert operation.
  • FALSE :执行更新插入或更新操作时,将目标对象中的数据更新为 NULL 值。FALSE : Update the data in the destination object to a null value when you do an upsert or update operation. 执行插入操作时插入 NULL 值。Insert a null value when you do an insert operation.
否。No. 默认值为 FALSEThe default value is FALSE .

备注

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

对于联机 Dynamics 365,存在每个组织进行两次并发批量调用的限制。For Dynamics 365 online, there's a limit of two concurrent batch calls per organization. 如果超出该限制,则会在运行第一个请求之前引发“服务器忙”异常。If that limit is exceeded, a "Server Busy" exception is thrown before the first request is ever run. 使 writeBatchSize 保持小于或等于 10 可避免这种并发调用限制。Keep writeBatchSize at 10 or less to avoid such throttling of concurrent calls.

writeBatchSizeparallelCopies 的最佳组合取决于实体的架构。The optimal combination of writeBatchSize and parallelCopies depends on the schema of your entity. 架构元素包括列数、行大小以及挂到这些调用的插件、工作流或工作流活动的数量。Schema elements include the number of columns, row size, and number of plug-ins, workflows, or workflow activities hooked up to those calls. 默认设置 writeBatchSize (10) × parallelCopies (10) 是基于 Dynamics 服务提供的建议设置。The default setting of writeBatchSize (10) × parallelCopies (10) is the recommendation according to the Dynamics service. 该值适用于大多数 Dynamics 实体,但可能无法提供最佳性能。This value works for most Dynamics entities, although it might not give the 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 table shows mappings from Dynamics data types to Data Factory interim data types. 若要了解复制活动如何映射到源架构以及数据类型如何映射到接收器,请参阅架构和数据类型映射To learn how a copy activity maps to a source schema and a data type maps to a sink, see Schema and data type mappings.

使用以下映射表,在基于源 Dynamics 数据类型的数据集结构中配置相应的数据工厂数据类型:Configure the corresponding Data Factory data type in a dataset structure that is 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.CalendarRulesAttributeType.MultiSelectPicklistAttributeType.PartyList 不受支持。The Dynamics data types AttributeType.CalendarRules , AttributeType.MultiSelectPicklist , and AttributeType.PartyList aren't supported.

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

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

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

    • 如果所有记录都映射到同一目标实体,请确保满足以下条件之一:If all records map to the same target entity, ensure one of the following conditions:
      • 源数据包含一个可存储目标实体名称的列。Your source data has a column that stores the target entity name.
      • 你已在复制活动源中添加了一个额外的列来定义目标实体。You've added an additional column in the copy activity source to define the target entity.
    • 如果不同的记录映射到不同的目标实体,请确保源数据包含一个可存储相应目标实体名称的列。If different records map to different target entities, make sure your source data has a column that 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 must be mapped to a virtual column with the special naming pattern {lookup_field_name}@EntityReference. 此列实际上并不存在于 Dynamics 中。The column doesn't actually exist in Dynamics. 它用来指示此列是给定多目标查找字段的元数据列。It's used to indicate this column is the metadata column of the given multitarget lookup field.

例如,假设源包含下面的两个列:For example, assume the source has these two columns:

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

另外假设你希望将此类数据复制到类型为 Customer 的接收器 Dynamics 实体字段 CustomerFieldAlso assume you want to copy such data to the sink Dynamics entity field CustomerField of type Customer .

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

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

Dynamics 查找字段列映射

如果所有源记录都映射到同一目标实体,并且源数据不包含目标实体名称,则可使用下面的快捷方式:在复制活动源中添加一个额外的列。If all of your source records map to the same target entity and your source data doesn't contain the target entity name, here is a shortcut: in the copy activity source, add an additional column. 使用模式 {lookup_field_name}@EntityReference 命名新列,将值设置为目标实体名称,然后按常规方式进行列映射。Name the new column by using the pattern {lookup_field_name}@EntityReference, set the value to the target entity name, then proceed with column mapping as usual. 如果源和接收器列名称相同,则还可跳过显式列映射,因为默认情况下,复制活动按名称映射列。If your source and sink column names are identical, you can also skip explicit column mapping because copy activity by default maps columns by name.

Dynamics 查找字段:添加实体引用列

查找活动属性Lookup activity properties

若要了解有关属性的详细信息,请参阅“查找”活动To learn details about the properties, see Lookup activity.

后续步骤Next steps

若要获取数据工厂中的复制活动支持将其用作源和接收器的数据存储的列表,请参阅支持的数据存储For a list of data stores the copy activity in Data Factory supports as sources and sinks, see Supported data stores.