Copy data from Xero using Azure Data Factory

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.

Important

This connector is currently in preview. You can try it out and provide feedback. If you want to take a dependency on preview connectors in your solution, please contact Azure support.

Supported capabilities

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.

Specifically, this Xero connector supports:

  • Xero private application but not public application.
  • All Xero tables (API endpoints) except "Reports".

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

You can create a pipeline with the copy activity by using one of the following tools or SDKs. Select a link to go to a tutorial with step-by-step instructions to create a pipeline with a copy activity.

The following sections provide details about properties that are used to define Data Factory entities specific to Xero connector.

Linked service properties

The following properties are supported for Xero linked service:

Property Description Required
type The type property must be set to: Xero Yes
host The endpoint of the Xero server (api.xero.com). Yes
consumerKey The consumer key associated with the Xero application. Mark this field as a SecureString to store it securely in Data Factory, or reference a secret stored in Azure Key Vault. Yes
privateKey The private key from the .pem file that was generated for your Xero private application, see Create a public/private key pair. Note to generate the privatekey.pem with numbits of 512 using openssl genrsa -out privatekey.pem 512; 1024 is not supported. Include all the text from the .pem file including the Unix line endings(\n), see sample below.

Mark this field as a SecureString to store it securely in Data Factory, or reference a secret stored in Azure Key Vault.
Yes
useEncryptedEndpoints Specifies whether the data source endpoints are encrypted using HTTPS. The default value is true. No
useHostVerification Specifies whether the host name is required in the server's certificate to match the host name of the server when connecting over SSL. The default value is true. No
usePeerVerification Specifies whether to verify the identity of the server when connecting over SSL. 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:

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. This section provides a list of properties supported by Xero dataset.

To copy data from Xero, set the type property of the dataset to XeroObject. There is no additional type-specific property in this type of dataset.

Example

{
    "name": "XeroDataset",
    "properties": {
        "type": "XeroObject",
        "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. This section provides a list of properties supported by Xero source.

Xero as source

To copy data from Xero, set the source type in the copy activity to XeroSource. The following properties are supported in the copy activity source section:

Property Description Required
type The type property of the copy activity source must be set to: XeroSource Yes
query Use the custom SQL query to read data. For example: "SELECT * FROM Contacts". Yes

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

Note the following when specifying the Xero query:

  • Tables with complex items will be split to multiple tables. 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 data is available through two schemas: Minimal (default) and Complete. 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. To reduce the number of API calls, use Minimal schema (default).

  • Bank_Transactions
  • Contact_Groups
  • Contacts
  • Contacts_Sales_Tracking_Categories
  • Contacts_Phones
  • Contacts_Addresses
  • Contacts_Purchases_Tracking_Categories
  • Credit_Notes
  • Credit_Notes_Allocations
  • Expense_Claims
  • Expense_Claim_Validation_Errors
  • Invoices
  • Invoices_Credit_Notes
  • Invoices_ Prepayments
  • Invoices_Overpayments
  • Manual_Journals
  • Overpayments
  • Overpayments_Allocations
  • Prepayments
  • Prepayments_Allocations
  • Receipts
  • Receipt_Validation_Errors
  • Tracking_Categories

The following tables can only be queried with complete schema:

  • Complete.Bank_Transaction_Line_Items
  • Complete.Bank_Transaction_Line_Item_Tracking
  • Complete.Contact_Group_Contacts
  • Complete.Contacts_Contact_ Persons
  • Complete.Credit_Note_Line_Items
  • Complete.Credit_Notes_Line_Items_Tracking
  • Complete.Expense_Claim_ Payments
  • Complete.Expense_Claim_Receipts
  • Complete.Invoice_Line_Items
  • Complete.Invoices_Line_Items_Tracking
  • Complete.Manual_Journal_Lines
  • Complete.Manual_Journal_Line_Tracking
  • Complete.Overpayment_Line_Items
  • Complete.Overpayment_Line_Items_Tracking
  • Complete.Prepayment_Line_Items
  • Complete.Prepayment_Line_Item_Tracking
  • Complete.Receipt_Line_Items
  • Complete.Receipt_Line_Item_Tracking
  • Complete.Tracking_Category_Options

Next steps

For a list of supported data stores by the copy activity, see supported data stores.