CData Cmdlets Module for ADLS は、直感的なAzure Data Lake Storage データ連携を提供する標準cmdlet です。
本記事では、ADLS Cmdlets を使ったサンプルを提供します。
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:
- 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.
$conn = Connect-ADLS -Schema "$Schema" -Account "$Account" -FileSystem "$FileSystem" -AccessKey "$AccessKey"
Azure Data Lake Storage データを取得してCSV にパイプライン
次の手順で、Resources テーブルデータを取得して、結果をCSV ファイルにエクスポートします:
Select-ADLS -Connection $conn -Table Resources | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myResourcesData.csv -NoTypeInformation
このように、Select-ADLS から取得した結果を、Select-Object cmdlet に流し、Export-Csv cmdlet に渡す前にいくつかのプロパティを除外しています。これは、CData Cmdlets が接続情報、テーブル、およびカラム情報が結果セットのそれぞれの"行"に挿入されるためです。それらの情報を表示したくない場合に、Export-Csv cmdlet に渡す前に除外を先に行い、それからCSV ファイルにエクスポートします。。
CData Cmdlets から、次のCmdlets にデータをパイプラインするところでは、接続、テーブル、カラムの情報が必要です。
このように、CData Cmdlets でデータ連携をシンプルに構成できます。Cmdlets では、モジュールのインストール、接続プロパティの設定だけで、データ連携の構築を始めることができます。是非、CData PowerShell Cmdlets の無償試用版をダウンロードして、シンプルかつパワフルなデータ連携を体感してください。