使用 Azure 数据工厂从 Xero 复制数据Copy data from Xero using Azure Data Factory

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

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

支持的功能Supported capabilities

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

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

具体而言,此 Xero 连接器支持:Specifically, this Xero connector supports:

  • Xero 专用应用程序,而不是公共应用程序。Xero private application but not public application.
  • 除“报告”外的所有 Xero 表(API 终结点)。All Xero tables (API endpoints) except "Reports".

Azure 数据工厂提供内置的驱动程序用于启用连接,因此无需使用此连接器手动安装任何驱动程序。Azure Data Factory provides a built-in driver to enable connectivity, therefore you don't need to manually install any driver using this connector.

入门Getting started

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

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

链接服务属性Linked service properties

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

属性Property 说明Description 必须Required
typetype type 属性必须设置为:XeroThe type property must be set to: Xero Yes
hosthost Xero 服务器的终结点 (api.xero.com)。The endpoint of the Xero server (api.xero.com). Yes
consumerKeyconsumerKey 与 Xero 应用程序关联的使用者密钥。The consumer key associated with the Xero application. 将此字段标记为 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
privateKeyprivateKey 为 Xero 专用应用程序生成的 .pem 文件中的私钥,请参阅创建公钥/私钥对The private key from the .pem file that was generated for your Xero private application, see Create a public/private key pair. 注意:使用 openssl genrsa -out privatekey.pem 512 可生成数位为 512 的 privatekey.pem,不支持生成 1024 数位 。Note to generate the privatekey.pem with numbits of 512 using openssl genrsa -out privatekey.pem 512; 1024 is not supported. 包括 .pem 文件中的所有文本,包括 Unix 行尾(\n),请参见下面的示例。Include all the text from the .pem file including the Unix line endings(\n), see sample below.

将此字段标记为 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
useEncryptedEndpointsuseEncryptedEndpoints 指定是否使用 HTTPS 加密数据源终结点。Specifies whether the data source endpoints are encrypted using HTTPS. 默认值为 true。The default value is true. No
useHostVerificationuseHostVerification 指定通过 TLS 进行连接时是否要求服务器证书中的主机名与服务器的主机名匹配。Specifies whether the host name is required in the server's certificate to match the host name of the server when connecting over TLS. 默认值为 true。The default value is true. No
usePeerVerificationusePeerVerification 指定通过 TLS 进行连接时是否要验证服务器的标识。Specifies whether to verify the identity of the server when connecting over TLS. 默认值为 true。The default value is true. No

示例:Example:

{
    "name": "XeroLinkedService",
    "properties": {
        "type": "Xero",
        "typeProperties": {
            "host" : "api.xero.com",
            "consumerKey": {
                 "type": "SecureString",
                 "value": "<consumerKey>"
            },
            "privateKey": {
                 "type": "SecureString",
                 "value": "<privateKey>"
            }
        }
    }
}

示例私钥值:Sample private key value:

包括 .pem 文件中的所有文本,包括 Unix 行尾(\n)。Include all the text from the .pem file including the Unix line endings(\n).

"-----BEGIN RSA PRIVATE KEY-----\nMII***************************************************P\nbu****************************************************s\nU/****************************************************B\nA*****************************************************W\njH****************************************************e\nsx*****************************************************l\nq******************************************************X\nh*****************************************************i\nd*****************************************************s\nA*****************************************************dsfb\nN*****************************************************M\np*****************************************************Ly\nK*****************************************************Y=\n-----END RSA PRIVATE KEY-----"

数据集属性Dataset properties

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

要从 Xero 复制数据,请将数据集的 type 属性设置为“XeroObject” 。To copy data from Xero, set the type property of the dataset to XeroObject. 支持以下属性:The following properties are supported:

属性Property 说明Description 必须Required
typetype 数据集的 type 属性必须设置为:XeroObjectThe type property of the dataset must be set to: XeroObject Yes
tableNametableName 表的名称。Name of the table. 否(如果指定了活动源中的“query”)No (if "query" in activity source is specified)

示例Example

{
    "name": "XeroDataset",
    "properties": {
        "type": "XeroObject",
        "typeProperties": {},
        "schema": [],
        "linkedServiceName": {
            "referenceName": "<Xero linked service name>",
            "type": "LinkedServiceReference"
        }
    }
}

复制活动属性Copy activity properties

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

以 Xero 作为源Xero as source

要从 Xero 复制数据,请将复制活动中的源类型设置为“XeroSource” 。To copy data from Xero, set the source type in the copy activity to XeroSource. 复制活动source部分支持以下属性:The following properties are supported in the copy activity source section:

属性Property 说明Description 必须Required
typetype 复制活动 source 的 type 属性必须设置为:XeroSourceThe type property of the copy activity source must be set to: XeroSource Yes
查询query 使用自定义 SQL 查询读取数据。Use the custom SQL query to read data. 例如:"SELECT * FROM Contacts"For example: "SELECT * FROM Contacts". 否(如果指定了数据集中的“tableName”)No (if "tableName" in dataset is specified)

示例:Example:

"activities":[
    {
        "name": "CopyFromXero",
        "type": "Copy",
        "inputs": [
            {
                "referenceName": "<Xero input dataset name>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<output dataset name>",
                "type": "DatasetReference"
            }
        ],
        "typeProperties": {
            "source": {
                "type": "XeroSource",
                "query": "SELECT * FROM Contacts"
            },
            "sink": {
                "type": "<sink type>"
            }
        }
    }
]

指定 Xero 查询时,请注意以下事项:Note the following when specifying the Xero query:

  • 包含复杂项的表将拆分为多个表。Tables with complex items will be split to multiple tables. 例如,银行事务具有复杂数据结构“LineItems”,因此银行事务数据将映射到表 Bank_TransactionBank_Transaction_Line_Items,并使用 Bank_Transaction_ID 作为外键将这些表链接在一起。For example, Bank transactions has a complex data structure "LineItems", so data of bank transaction is mapped to table Bank_Transaction and Bank_Transaction_Line_Items, with Bank_Transaction_ID as foreign key to link them together.

  • 可通过两个架构使用 Xero 数据:Minimal(默认值)和 CompleteXero data is available through two schemas: Minimal (default) and Complete. 完整架构包含先决条件调用表,这些表在进行所需的查询之前需要其他数据(例如 ID 列)。The Complete schema contains prerequisite call tables which require additional data (e.g. ID column) before making the desired query.

以下表的最小架构和完整架构具有相同信息。The following tables have the same information in the Minimal and Complete schema. 若要减少 API 调用数,请使用最小架构(默认值)。To reduce the number of API calls, use Minimal schema (default).

  • Bank_TransactionsBank_Transactions
  • Contact_GroupsContact_Groups
  • 联系人Contacts
  • Contacts_Sales_Tracking_CategoriesContacts_Sales_Tracking_Categories
  • Contacts_PhonesContacts_Phones
  • Contacts_AddressesContacts_Addresses
  • Contacts_Purchases_Tracking_CategoriesContacts_Purchases_Tracking_Categories
  • Credit_NotesCredit_Notes
  • Credit_Notes_AllocationsCredit_Notes_Allocations
  • Expense_ClaimsExpense_Claims
  • Expense_Claim_Validation_ErrorsExpense_Claim_Validation_Errors
  • 发票Invoices
  • Invoices_Credit_NotesInvoices_Credit_Notes
  • Invoices_PrepaymentsInvoices_ Prepayments
  • Invoices_OverpaymentsInvoices_Overpayments
  • Manual_JournalsManual_Journals
  • OverpaymentsOverpayments
  • Overpayments_AllocationsOverpayments_Allocations
  • PrepaymentsPrepayments
  • Prepayments_AllocationsPrepayments_Allocations
  • ReceiptsReceipts
  • Receipt_Validation_ErrorsReceipt_Validation_Errors
  • Tracking_CategoriesTracking_Categories

以下表只能使用完整架构查询:The following tables can only be queried with complete schema:

  • Complete.Bank_Transaction_Line_ItemsComplete.Bank_Transaction_Line_Items
  • Complete.Bank_Transaction_Line_Item_TrackingComplete.Bank_Transaction_Line_Item_Tracking
  • Complete.Contact_Group_ContactsComplete.Contact_Group_Contacts
  • Complete.Contacts_Contact_PersonsComplete.Contacts_Contact_ Persons
  • Complete.Credit_Note_Line_ItemsComplete.Credit_Note_Line_Items
  • Complete.Credit_Notes_Line_Items_TrackingComplete.Credit_Notes_Line_Items_Tracking
  • Complete.Expense_Claim_PaymentsComplete.Expense_Claim_ Payments
  • Complete.Expense_Claim_ReceiptsComplete.Expense_Claim_Receipts
  • Complete.Invoice_Line_ItemsComplete.Invoice_Line_Items
  • Complete.Invoices_Line_Items_TrackingComplete.Invoices_Line_Items_Tracking
  • Complete.Manual_Journal_LinesComplete.Manual_Journal_Lines
  • Complete.Manual_Journal_Line_TrackingComplete.Manual_Journal_Line_Tracking
  • Complete.Overpayment_Line_ItemsComplete.Overpayment_Line_Items
  • Complete.Overpayment_Line_Items_TrackingComplete.Overpayment_Line_Items_Tracking
  • Complete.Prepayment_Line_ItemsComplete.Prepayment_Line_Items
  • Complete.Prepayment_Line_Item_TrackingComplete.Prepayment_Line_Item_Tracking
  • Complete.Receipt_Line_ItemsComplete.Receipt_Line_Items
  • Complete.Receipt_Line_Item_TrackingComplete.Receipt_Line_Item_Tracking
  • Complete.Tracking_Category_OptionsComplete.Tracking_Category_Options

Lookup 活动属性Lookup activity properties

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

后续步骤Next steps

有关复制活动支持的数据存储列表,请参阅支持的数据存储For a list of supported data stores by the copy activity, see supported data stores.