Hantera OneLake med PowerShell

OneLake integreras med modulen Azure PowerShell för dataläsning, skrivning och hantering.

Ansluta till OneLake med Azure PowerShell

Anslut till OneLake från PowerShell genom att följa dessa steg:

  1. Installera Azure Storage PowerShell-modulen.

    Install-Module Az.Storage -Repository PSGallery -Force
    
  2. Logga in på ditt Azure-konto.

    Connect-AzAccount
    
  3. Skapa kontexten för lagringskontot.

    • Lagringskontonamnet är onelake.
    • Ställ in -UseConnectedAccount för att vidarebefordra dina Azure-behörighetsuppgifter.
    • Ange -endpoint som fabric.microsoft.com.
  4. Kör samma kommandon som används för Azure Data Lake Storage (ADLS) Gen2. Mer information om ADLS Gen2 och Azure Storage PowerShell-modulen finns i Använda PowerShell för att hantera ADLS Gen2.

Exempel: Hämta storleken på ett objekt eller en katalog

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"