ODBC Driver for ADLS からSQL Gateway を使用し、MySQL インターフェースを介してAzure Data Lake Storage にクエリを実行できます。以下のステップに従って、SQL Gateway のMySQL リモーティングサービスを開始し、MySQL Workbench でライブAzure Data Lake Storage を操作します。
Azure Data Lake Storage データへの接続
未指定の場合は、データソース名(DSN)で必要な接続プロパティの値を指定します。DSN を構成するために、ビルトインのMicrosoft ODBC Data Source Administrator を使用できます。ドライバーのインストールの最後にアドミニストレーターが開きます。Microsoft ODBC データソースアドミニストレーターでDSN を作成及び設定する方法については、ヘルプドキュメントの[はじめに]チャプターを参照してください。
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.
SQL Gateway を構成する
Azure Data Lake Storage への接続を仮想MySQL データベースとして設定するには、SQL Gateway Overview を参照してください。クライアントからのMySQL 要求を受けるMySQL リモートサービスを構成します。このサービスは、SQL Gateway UI で構成できます。
![Creating a MySQL Remoting Service in SQL Gateway (Salesforce is shown)]()
MySQL Workbench からAzure Data Lake Storage をクエリ
以下のステップでは、MySQL Workbench からSQL Gateway で作成された仮想Azure Data Lake Storage データベースに接続し、ライブAzure Data Lake Storage データを操作するための基本的なクエリを発行する方法を説明します。
SQL Gateway を介してAzure Data Lake Storage に接続
- MySQL Workbench で、[add a new MySQL connection]をクリックします。
- 接続(CData SQL Gateway for ADLS)に名前を付けます。
- Hostname、Port、Username のパラメータを設定し、SQL Gateway に接続します。
- Store in Vault をクリックしてパスワードを設定し、保存します。
- Test Connection をクリックして接続が正しく構成されていることを確認し、OK をクリックします。
Azure Data Lake Storage データをクエリ
- 作成した接続(CData SQL Gateway for ADLS)を開きます。
- [File]->[New Query Tab]と進みます。
- SELECT * FROM `CData ADLS Sys`.Resources; のようなAzure Data Lake Storage データを取得するSQL クエリを記述します。
MySQL Workbench からライブAzure Data Lake Storage データにアクセスすることで、MySQL データベースと同じようにAzure Data Lake Storage をクエリおよび更新できます。CData ODBC Driver for ADLS とCData SQL Gateway の30日の無償評価版はこちらです。