CData JDBC Driver for ADLS はAzure Data Lake Storage データをMule アプリケーションと連携することで、読みといった機能をおなじみのSQL クエリを使って実現します。JDBC ドライバーを使えば、Azure Data Lake Storage データをバックアップ、変換、レポート作成、分析するMule アプリケーションをユーザーは簡単に作成できます。
本記事では、Mule プロジェクト内でCData JDBC Driver for ADLS を使用して、Azure Data Lake Storage データのWeb インターフェースを作成する方法を紹介します。作成したアプリケーションを使えば、HTTP 経由でAzure Data Lake Storage データをリクエストして、JSON 形式で結果を取得できます。まったく同様の手順で、すべてのCData JDBC Driver で240 を超えるデータソースのWeb インターフェースを作成できます。手順は以下のとおりです。
- Anypoint Studio で新しいMule プロジェクトを作る。
- Message Flow にHTTP コネクタを追加する。
- HTTP コネクタのアドレスを設定する。
![HTTP コネクタを追加・設定]()
- HTTP コネクタの追加後、Database Select コネクタを同じフローに追加する。
- データベースへの新しい接続を作成し(または既存の接続を編集し)、プロパティを設定する。
- 接続を「Generic Connection」に設定
- Required Libraries セクションでCData JDBC Driver のJAR ファイルを指定する(例:cdata.jdbc.adls.jar)。
- Azure Data Lake Storage の接続文字列にURL を指定
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:
- Sign in to your Azure Account through the
[.
]- Select "Azure Active Directory".
- Select "App registrations".
- Select "New application registration".
- Provide a name and URL for the application. Select Web app for the type of application you want to create.
- Select "Required permissions" and change the required permissions for this app. At a minimum, "Azure Data Lake" and "Windows Azure Service Management API" are required.
- Select "Key" and generate a new key. Add a description, a duration, and take note of the generated key. You won't be able to see it again.
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.
組み込みの接続文字列デザイナ
JDBC 用のURL の作成にサポートが必要な場合は、Azure Data Lake Storage JDBC Driver に組み込まれた接続文字列デザイナを使用できます。JAR ファイルをダブルクリックするか、コマンドラインからJAR ファイルを実行してください。
java -jar cdata.jdbc.adls.jar
接続プロパティを入力して、接続文字列をクリップボードにコピーします。
- Driver クラス名をcdata.jdbc.adls.ADLSDriver に指定します。
- 「接続テスト」をクリックします。
- SQL Query Text をAzure Data Lake Storage データをリクエストするためのSQL クエリに設定します。例えば、
SELECT FullPath, Permission FROM Resources WHERE Type = 'FILE'
。
- Transform Message コンポーネントをフローに追加します。
- Output スクリプトを次のように設定して、ペイロードをJSON に変換します。
%dw 2.0
output application/json
---
payload
- Azure Data Lake Storage データを閲覧するには、HTTP コネクタ用に設定したアドレスに移動します(デフォルトでは、localhost:8081):http://localhost:8081。Web ブラウザおよびJSON エンドポイントを使用可能な他のツール内で、Azure Data Lake Storage データをJSON として利用できます。
これで、カスタムアプリケーションおよび他のさまざまなBI、帳票、ETL ツールからAzure Data Lake Storage データを(JSON データとして)扱うための簡易なWeb インターフェースを作成できました。Mule アプリケーションからお好みのデータソースにアクセスできる、JDBC Driver for ADLS の30日の無償評価版のダウンロードはこちらから。