Mengelola OneLake dengan PowerShell

Microsoft OneLake terintegrasi dengan modul Azure PowerShell untuk pembacaan, penulisan, dan manajemen data.

Menyambungkan ke OneLake dengan Azure PowerShell

Sambungkan ke OneLake dari PowerShell dengan mengikuti langkah-langkah berikut:

  1. Instal modul Azure Storage PowerShell.

    Install-Module Az.Storage -Repository PSGallery -Force
    
  2. Masuk menggunakan akun Azure Anda.

    Connect-AzAccount
    
  3. Buat konteks akun penyimpanan.

    • Nama akun penyimpanan adalah onelake.
    • Atur -UseConnectedAccount agar kredensial Azure Anda mengalirkan langsung.
    • Atur -endpoint sebagai fabric.microsoft.com.
  4. Jalankan perintah yang sama yang digunakan untuk Azure Data Lake Storage (ADLS) Gen2. Untuk informasi selengkapnya tentang ADLS Gen2 dan modul Azure Storage PowerShell, lihat Menggunakan PowerShell untuk mengelola ADLS Gen2.

Contoh: Dapatkan ukuran item atau direktori

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"