製品をチェック

製品についての詳細情報や無償トライアルをご案内します:

API Server

データ連携でお困りですか?

お問い合わせ

Azure Data Lake Storage データをAI アシスタントのPEP から利用する方法


AI アシスタントPEP から Azure Data Lake Storage データに連携し、チャットボットでリアルタイムAzure Data Lake Storage データを使う方法


杉本和也
リードエンジニア

azuredatalake ロゴ画像

API Server

apiserver ロゴ画像
PEP ロゴ画像

CData API Server と ADO.NET Provider / JDBC Driver for ADLS を使って、AI アシスタントPEP(https://pep.work/) から Azure Data Lake Storage に接続して、チャットボットでリアルタイムAzure Data Lake Storageデータを使った応答を可能にする方法を説明します。

API Server の設定

次のステップに従い、セキュアな REST API サービスを立ち上げます

デプロイ

API Server はサーバー上で稼働します。Windows 版は、製品に組み込まれているスタンドアロンのサーバーかIIS に配置して稼働させることができます。Java 版では、Java servlet コンテナにAPI Server のWAR ファイルを配置します。 デプロイの詳細は製品ヘルプを参照してください。API Server を Microsoft AzureAmazon EC2Heroku にデプロイする方法はKB に記事があります。

Azure Data Lake Storage への接続

API Server の管理コンソールで[設定]→[接続]から新しい接続を追加してAzure Data Lake Storage を追加します。

Azure Data Lake Storage のアイコンがデフォルトのAPI Server の接続先にない場合には、API Server がJava 版の場合はJDBC Drivers、API Server がWindows 版の場合はADO.NET Data ProvidersからAzure Data Lake Storage ドライバーをAPI Server と同じマシンにインストールして、API Server を再起動します。

Azure Data Lake Storage への接続に必要な認証情報を入力します。接続のテストを行い、接続を確認して、設定を保存します。

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:

  1. Sign in to your Azure Account through the .
  2. Select "Azure Active Directory".
  3. Select "App registrations".
  4. Select "New application registration".
  5. Provide a name and URL for the application. Select Web app for the type of application you want to create.
  6. 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.
  7. 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.

接続を確立後、[設定]→[リソース]の画面で からREST API として公開するエンティティを選択します。

API Server のユーザー設定

[設定]→[ユーザー]からAPI にアクセスできるユーザーの認証設定を行います。API Server はトークンでの認証を行うことができます。 IP アドレスでAPI へのアクセスを制限することも可能です。デフォルトではローカルマシンからのアクセスのみが許可されています。SSL の設定も可能です。

オンプレミスDB やファイルからのAPI Server 使用(オプション)

オンプレミスRDB やExcel/CSV などのファイルのデータを使用する場合には、API Server のCloug Gateway / SSH ポートフォワーディングが便利です。是非、Cloud Gatway の設定方法 記事を参考にしてください。

PEP でAzure Data Lake Storage データをチャットで使う設定

前項まででAPI ができたので、ここからはPEP 側での設定作業です。

PEP でAzure Data Lake Storage のAPI をコールするシナリオを作成

PEP 側ではあらかじめSlack などのアプリケーションを構成しておきます。ここにAPI Server をコールするAI アシスタントのシナリオを追加していきます。

PEP
  • 「会話編集」→「シナリオ」に移動し、新しいシナリオを作成します。
  • PEP
  • シナリオ名を入力します。この例では、条件はSlack Homeを 選択しています。
  • PEP
  • 「新規作成」ボタンをクリックすると、以下のようなシナリオエディタ画面に移動します。これでシナリオを作成する準備ができました。
  • PEP

Azure Data Lake Storage のAPI の接続箇所の設定

具体的にAPI連携を含めたシナリオを作っていきます。

  • 最初に検索したい文字列を受け取るための対話ノードを配置して、以下のように構成します。
  • PEP
  • ポイントは分岐条件で「以下のすべての会話」、発言内容の記憶で「film_name」として、会話した内容を変数に保存することです。
  • PEP
  • 対話ノードを配置したら、APIノードを追加して、対話ノードから接続していきます。
  • PEP
  • APIノードでは、以下のように CData API Server へのリクエストを構成します。
    ポイントは2つです。CData API Server は Filter 機能によって、取得するデータを絞り込むことができます。その指定が「$filter=contains(title,'{{ state.scenario_4.form.film_name }}')」の部分です。 「{{ state.scenario_4.form.film_name }}」は直前の対話ノードで設定した変数をパラメータとして渡しています。「scenario_4」はPEP のシナリオIDですので、作成したシナリオに合わせて変更してください。
  • HTTPヘッダーにAPI Server のユーザートークンを指定します。
    • API名:任意の名前を設定
    • URL:http://apiserverurl/api.rsc/film_list?$filter=contains(title,'{{ state.scenario_4.form.film_name }}')
    • HTTPメソッド:GET
    • Content-Type:JSON
    • HTTPヘッダー:キー「x-cdata-authtoken」、値「予め取得したAPI Serverのトークン」を指定
  • PEP

これで保存すると、API ノードが使えるようになります。

取得したAzure Data Lake Storage からのレスポンスの表示方法

最後に後続の対話ノードを構成し、取得した検索結果を表示します。

PEP

対話ノードの応答文には、以下のような文章を埋め込みます。

検索結果は以下のとおりです。 {% for item in state.scenario_4.api_response.film_search.value %} フィルムID:{{ item.FID }} タイトル : {{ item.title }} 値段:{{ item.price }} カテゴリー:{{ item.category }} 俳優: ----- {% endfor %} PEP

ここでポイントになるのは、API Server から受け取るJSONのレスポンスの分解方法です。 API Server のレスポンスはオブジェクト直下にvalueという配列要素があり、このレスポンスは「{{state.scenario_4.api_response.film_search.value}}」の形でアクセスできます。
設定イメージ:state.シナリオID.api_response.APIノード名.value
これを「FOR」での繰り返し処理で取得して、文章として表示する仕組みになっています。

PEP

これで設定は完了です。実際に動かしてみると、Azure Data Lake Storage →API Server → PEP 経由でデータを取得して表示していることがわかるかと思います。

CData API Server の無償版およびトライアル

CData API Server は、無償版および30日の無償トライアルがあります。是非、API Server ページ から製品をダウンロードしてお試しください。