Mengelola OneLake dengan PowerShell

Penting

Microsoft Fabric sedang dalam pratinjau.

Menyambungkan ke OneLake dengan Azure PowerShell

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

  1. Menginstal modul PowerShell Azure Storage.

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

    Connect-AzAccount
    
  3. Buat konteks akun penyimpanan.

    1. Nama akun penyimpanan adalah 'onelake'.
    2. Atur '-UseConnectedAccount' untuk melewati kredensial Azure Anda.
    3. Atur '-endpoint' sebagai 'fabric.microsoft.com'.
  4. Jalankan perintah yang sama yang digunakan untuk ADLS Gen2. Untuk informasi selengkapnya tentang ADLS Gen 2 dan modul Azure Storage PowerShell, lihat Menggunakan PowerShell untuk mengelola ADLS Gen2.

Contoh: Mendapatkan 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"