キャッシュ機能を使って、Azure Data Lake Storage の任意のエンドポイントをSQL Server にキャッシュ同期
Azure Data Lake Storage データをDB にコピーするニーズは多いです。例えば、データのバックアップのため、
データをDB にデータレイク的に格納して他のアプリケーションやBI、ETL ツールから連携利用するなどです。
ただし、JSON やXML 形式であったりスキーマレスなデータなどを、DB に格納できるようにスキーマ定義をしながらデータを同期することは大きな手間です。
しかも、SaaS やNoSQL などのデータはスキーマレスであったり、スキーマが頻繁に変更されます。
CData Driver 技術では、Azure Data Lake Storage データをテーブルにモデル化し、スキーマを付与してDB にへの格納を容易にします。
本記事では、CACHE コマンドだけで、SQL Server にAzure Data Lake Storage データの同期を取る方法を説明します。
※製品について詳しい情報をご希望の方は以下からお進みください。
- Azure Data Lake Storage にほかのBI、ETL、開発ツールから接続したい:Azure Data Lake Storage データ連携ガイドおよびチュートリアルのリストへ
- Azure Data Lake Storage Drivers について詳細を知りたい:ドライバー詳細情報ページへ
- ほかのデータソースに連携したい:CData Drivers 一覧へ
- ドライバーの30日の無償トライアル版を使いたい:トライアル版ダウンロードページへ
- 製品の利用やライセンスについて相談したい:sales@cdata.co.jp までメールにてご相談ください。
同期先となるデータベースの準備
この例では、SQL Server を使います。難しい手順は不要で、SQL Server に任意の名前の新しい同期DB を作成しておくだけです。

ODBC Driver for Azure Data Lake Storage のインストールとAzure Data Lake Storage への接続
ODBC 接続プロパティの指定がまだの場合は、DSN (データソース名)で接続設定を行います。 Microsoft ODBC データソースアドミニストレーターを使ってODBC DSN を作成および設定できます。 ODBC ドライバーのインストール完了時にODBC DSN 設定画面が立ち上がります。 Microsoft ODBC データソースアドミニストレーターを開いて設定を行うことも可能です。 必要なプロパティを設定する方法は、ヘルプドキュメントの「はじめに」をご参照ください。
Authenticating to a Gen 1 DataLakeStore Account
Gen 1 uses OAuth 2.0 in Azure AD for authentication.
For this, an Active Directory web application is required. You can create one as follows:
To authenticate against a Gen 1 DataLakeStore account, the following properties are required:
- Schema: Set this to ADLSGen1.
- Account: Set this to the name of the account.
- OAuthClientId: Set this to the application Id of the app you created.
- OAuthClientSecret: Set this to the key generated for the app you created.
- TenantId: Set this to the tenant Id. See the property for more information on how to acquire this.
- Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
Authenticating to a Gen 2 DataLakeStore Account
To authenticate against a Gen 2 DataLakeStore account, the following properties are required:
- Schema: Set this to ADLSGen2.
- Account: Set this to the name of the account.
- FileSystem: Set this to the file system which will be used for this account.
- AccessKey: Set this to the access key which will be used to authenticate the calls to the API. See the property for more information on how to acquire this.
- Directory: Set this to the path which will be used to store the replicated file. If not specified, the root directory will be used.
通常のDSN 設定に加え、キャッシュ関連項目の設定が必要です:
Cache Connection:以下をセミコロン区切りで入力
Cache Provider:SQL Server ではSystem.Data.SqlClient
Server=server name;Database=database name;User ID=your id;Password=password;

Visual Studio からキャッシュを実行
Visual Studio のサーバーエクスプローラーから「データ接続」を右クリックして「接続の追加」を選択します。
データソース選択画面で「Microsoft ODBC データソース」を選択します。

サーバーエクスプローラーには、「ODBC.Azure Data Lake Storage.CData」というコネクションができています。 展開するとAzure Data Lake Storage データがテーブルよびビューとしてモデル化されて表示されます。 これらのオブジェクトは通常のSQL で操作することができます。
キャッシュクエリの実行
以下のキャッシュコマンドを作成し、実行します。 実行時にクエリテキストエラーが出ても気にせず続行してください。
CACHE SELECT * FROM "Target Table"

キャッシュ結果をSQL Server で確認
データベースの下にkintone の選択したアプリが同期されています。キレイにDB 向けにスキーマも付いてます。普通にSQL でアプリケーション内で使ってください。