CData Excel Add-In for ADLS の関数を使って、スプレッドシートにデータを取り込むことができます。下記の3つの手順では、次のタスクを自動化する方法について説明します:ユーザー定義の値でAzure Data Lake Storage を検索し、その結果をExcel スプレッドシートに出力します。
CDATAQUERY 関数の構文は次のとおりです:
=CDATAQUERY(Query, [Connection], [Parameters], [ResultLocation]);
この関数に入力する値は以下の3つです:
- Query:取得したいAzure Data Lake Storage data レコードの宣言修正を簡単な構文で記述。
-
Connection:ADLSConnection1 のような接続名、もしくは接続文字列を入力。接続文字列は、Azure Data Lake Storage への接続に必要なプロパティのセミコロン区切りとなります。一般的な接続文字列は次のとおりです:
- Schema
- Account
- FileSystem
- AccessKey
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.
- ResultLocation:結果のアウトプットを開始するセル。
スプレッドシートのセルをクエリのインプットとして渡す
下記の処理では、すべての関数インプットをひとつ目のカラムでオーガナイズするスプレッドシートができます。
-
関数をインプットするセルを定義します。接続インプットに加えて、Type のように、Azure Data Lake Storage の検索に使われるフィルタ用の基準を定義する追加のインプットを入力します。
- 別のセルに、上で定義したユーザーインプットセルからセルの値を参照する関数を書きます。住所などスペースを含む可能性のある値は、シングルクオートで囲みます。
=CDATAQUERY("SELECT * FROM Resources WHERE Type = '"&B5&"'","Schema="&B1&";Account="&B2&";FileSystem="&B3&";AccessKey="&B4&";Provider=ADLS",B6)
- フィルタを変更してデータを変更します。