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:
Menginstal modul PowerShell Azure Storage.
Install-Module Az.Storage -Repository PSGallery -Force
Masuk menggunakan akun Azure Anda.
Connect-AzAccount
Buat konteks akun penyimpanan.
- Nama akun penyimpanan adalah 'onelake'.
- Atur '-UseConnectedAccount' untuk melewati kredensial Azure Anda.
- Atur '-endpoint' sebagai 'fabric.microsoft.com'.
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"