UiPath は高機能なRPA(Robotic Process Automation)製品です。UiPath Studioを使うことで、RPAプログラムをフローチャートを描くように開発することが可能です。
CData ODBC driver を使えば、コーディングなしでUiPath からAzure Data Lake Storage への連携フローを設定することができます。UiPath は、ODBC Driver に対してSQL を発行します。発行されたSQL をCData ODBC driver がAzure Data Lake Storage へのリアルタイムリクエストに変換し、レスポンスをテーブルデータとして取得します。
この記事では、UiPath Studio を使って、Azure Data Lake Storage に連携するRPA プログラムを作成します。
今回作成するUiPath RPA プロジェクト
以下のようなUiPath RPA プロジェクトを作成します。
「Connect Activity」を利用して、Azure Data Lake StorageCData ODBC driverに接続し、顧客リストを取得するSQLを実行。取得したDatatableを「Write CSV Activity」を利用してCSV出力します。
Azure Data Lake Storage ODBC Driver とUiPath Studio の連携
接続プロパティが未設定の場合は、まずODBC DSN(データソース名)で設定します。これはドライバーのインストールの最後の手順です。Microsoft ODBC データソースアドミニストレーターを使って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.
これで、UiPath StudioにAzure Data Lake Storage data を接続することができます。作業手順は以下です。
- スタートページからBlank をクリックして、新しいプロジェクトを作成します。新しいデータベースでFile -> Inport Records -> Data Source をクリックし、CData Azure Data Lake Storage DSN を選択します。プロジェクト名は任意の名称を設定します。
- Azure Data Lake Storage ODBC Driverの接続を行うためには、Database接続用のActivityが必要になります。
Activities ナビゲーションから[Manage Package]をクリックし、[UiPath.Database.Activities]を検索し、インストールします。
- ActivitiesからFlow chartを配置して、下準備は完了です。
- ODBC 接続に使用するConnect Activity を配置します。配置後ダブルクリックし、Connectの詳細を表示します。
- Connectの詳細画面にて、Configure Connectionをクリックし、Connection Wizard を表示します。Microsoft ODBC Data Source を選択します。
- use user or system data source name:から作成したCData Azure Data Lake Storage Source DSNをドロップダウンで選択します。OK を押して接続を確立します。
- Connection 情報を格納するための変数を作成し、Propetries のOutput で、DatabaseConnection を指定し、紐付けを行います。
Execute Query Activity の作成
次に先程作成したODBC Connection 情報を使って、ODBC からデータを取り出すクエリを実行するためのExecute Query Activity を作成します。
- Activities ナビゲーションから[Execute Query]を選択し、Flowchartに配置します。
- Propertiesに以下のように値を入力します。
ExistingDbConnection: 先程作成したConneciton変数を入力します。
Sql: Azure Data Lake Storage の対象リストを取得するSELECT 文を入力します。
DataTable: DataTable型の変数を作成し、入力します。
Write CSV の作成
最後のActivityとして、取得したDataTableをCSV出力するActivityを配置します。[FilePath]に出力するCSVのフォルダパスとファイル名(例:"C:\UiPath\Sample.csv")、DataTableに先程作成したDataTable変数を紐づけます。
各Activity の接続と実行
あとは各Activityを紐付ければ、Azure Data Lake Storage データを出力するRPA プロジェクトの作成は完了です。
RUN をクリックすると、自動的にAzure Data Lake Storage のデータを取得し、CSVが生成されます。
このようにCData ODBC Drivers を利用して、簡単にUiPath Studio でAzure Data Lake Storage に連携するフローを作成することができます。