PowerShell を使用して OneLake を管理する

Microsoft Fabric OneLake は、データの読み取り、書き込み、管理のための Azure PowerShell モジュールと統合されています。

Azure PowerShell を使用して OneLake に接続する

次の手順に従って、PowerShell から OneLake に接続します。

  1. Azure Storage PowerShell モジュールをインストールします。

    Install-Module Az.Storage -Repository PSGallery -Force
    
  2. Azure アカウントへサインインします。

    Connect-AzAccount
    
  3. ストレージ アカウント コンテキストを作成します。

    • ストレージ アカウント名は 「onelake」 です。
    • Azure 資格情報をパススルーするように -UseConnectedAccount を設定します。
    • -endpointfabric.microsoft.com として設定します。
  4. Azure Data Lake Storage (ADLS) Gen2 に使用されるのと同じコマンドを実行します。 ADLS Gen2 と Azure Storage PowerShell モジュールの詳細については、「PowerShell を使用して ADLS Gen2 を管理する」を参照してください。

例: 項目またはディレクトリのサイズを取得する

Install-Module Az.Storage -Repository PSGallery -Force
Connect-AzAccount
$ctx = New-AzStorageContext -StorageAccountName 'onelake' -UseConnectedAccount -endpoint 'fabric.microsoft.com' 

# This example uses the workspace and item name. If the workspace name does not meet Azure Storage naming criteria (no special characters), you can use GUIDs instead.
$workspaceName = 'myworkspace'
$itemPath = 'mylakehouse.lakehouse/Files'

# Recursively get the length of all files within your lakehouse, sum, and convert to GB.
$colitems = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $workspaceName -Path $itemPath -Recurse -FetchProperty | Measure-Object -property Length -sum
"Total file size: " + ($colitems.sum / 1GB) + " GB"