Replicate Multiple Microsoft OneLake Accounts via the CData Sync CLI



Replicate multiple Microsoft OneLake accounts to one or many databases.

CData Sync for Microsoft OneLake is a stand-alone application that provides solutions for a variety of replication scenarios such as replicating sandbox and production instances into your database. Both Sync for Windows and Sync for Java include a command-line interface (CLI) that makes it easy to manage multiple Microsoft OneLake connections. In this article we show how to use the CLI to replicate multiple Microsoft OneLake accounts.

Configure Microsoft OneLake Connections

You can save connection and email notification settings in an XML configuration file. To replicate multiple Microsoft OneLake accounts, use multiple configuration files. Below is an example configuration to replicate Microsoft OneLake to SQLite:

Windows

<?xml version="1.0" encoding="UTF-8" ?> <CDataSync> <DatabaseType>SQLite</DatabaseType> <DatabaseProvider>System.Data.SQLite</DatabaseProvider> <ConnectionString></ConnectionString> <ReplicateAll>False</ReplicateAll> <NotificationUserName></NotificationUserName> <DatabaseConnectionString>Data Source=C:\my.db</DatabaseConnectionString> <TaskSchedulerStartTime>09:51</TaskSchedulerStartTime> <TaskSchedulerInterval>Never</TaskSchedulerInterval> </CDataSync>

Java

<?xml version="1.0" encoding="UTF-8" ?> <CDataSync> <DatabaseType>SQLite</DatabaseType> <DatabaseProvider>org.sqlite.JDBC</DatabaseProvider> <ConnectionString></ConnectionString> <ReplicateAll>False</ReplicateAll> <NotificationUserName></NotificationUserName> <DatabaseConnectionString>Data Source=C:\my.db</DatabaseConnectionString> </CDataSync>

To connect with Microsoft OneLake, set the following connection properties:

  • Connection Name - Enter a connection name of your choice.
  • File Format - Select the file format that you want to use. Sync supports the CSV, PARQUET, and AVRO file formats.
  • Azure Storage Account - Enter the name of your Azure storage account.
  • URI - Enter the path of the file system and folder that contains your files. For example, onelake://Workspace/Test.LakeHouse/Files/CustomFolder

CData Sync supports authenticating to Microsoft OneLake in several ways. For Azure Active Directory, please see the instructions below.

Azure Active Directory

To connect with an Azure Active Directory (AD) user account, select "Azure AD" for Auth Scheme. CData Sync provides an embedded OAuth application with which to connect so no additional properties are required.

For other authentication methods (see below), refer to the Help documentation.

Other Supported Authentication Methods

  • Azure Service Principal
  • Azure Service Principal Certificate
  • Azure Managed Service Identity

Configure Queries for Each Microsoft OneLake Instance

Sync enables you to control replication with standard SQL. The REPLICATE statement is a high-level command that caches and maintains a table in your database. You can define any SELECT query supported by the Microsoft OneLake API. The statement below caches and incrementally updates a table of Microsoft OneLake data:

REPLICATE MyFolder;

You can specify a file containing the replication queries you want to use to update a particular database. Separate replication statements with semicolons. The following options are useful if you are replicating multiple Microsoft OneLake accounts into the same database:

You can use a different table prefix in the REPLICATE SELECT statement:

REPLICATE PROD_MyFolder SELECT * FROM MyFolder

Alternatively, you can use a different schema:

REPLICATE PROD.MyFolder SELECT * FROM MyFolder

Run Sync

After you have configured the connection strings and replication queries, you can run Sync with the following command-line options:

Windows

OneLakeSync.exe -g MyProductionOneLakeConfig.xml -f MyProductionOneLakeSync.sql

Java

java -Xbootclasspath/p:c:\sqlitejdbc.jar -jar OneLakeSync.jar -g MyProductionOneLakeConfig.xml -f MyProductionOneLakeSync.sql

Ready to get started?

Learn more or sign up for a free trial:

CData Sync