OneLake 會自動透過軟刪除保護您的資料,該功能會保留已刪除的檔案七天,然後才永久移除。 這種內建保護幫助你從意外刪除或使用者錯誤中恢復,無需從備份還原。
七天後,軟刪除的檔案會永久移除,無法恢復。
你支付軟刪除資料的費用與活躍資料相同。
還原軟刪除的檔案
你可以透過使用 Azure Storage Explorer、Azure PowerShell 或 Azure Storage REST API 來恢復軟刪除的檔案。 您需要對檔案擁有寫入權限才能還原它們。
使用 Azure Storage Explorer 還原檔案
Azure 儲存檔案總管提供視覺化介面,用以瀏覽和還原軟刪除的檔案。
要使用 Azure Storage Explorer 還原檔案,請確保你具備:
- Azure Storage Explorer 安裝在您的電腦上
- 連接您的 OneLake 工作空間。 相關說明請參見「 使用 Azure Storage Explorer 搭配 OneLake」。
請使用以下步驟來還原檔案:
打開 Azure Storage Explorer 並連接到你的 OneLake 工作空間。
前往包含已刪除檔案的資料湖倉或資料項目。
選取路徑列旁的下拉式按鈕,然後選取 作用中和虛刪除的 Blob,而不是預設的 作用中 Blob。
瀏覽包含已刪除檔案的資料夾。
右鍵點擊軟刪除的檔案,然後選擇 取消刪除。
檔案會被還原到原始位置,並立即可用。
使用 PowerShell 還原檔案
使用 Azure PowerShell 以程式化方式列出並還原軟刪除的檔案。
要使用 PowerShell 還原檔案,請確保你具備:
- Azure PowerShell Az.Storage module 已安裝
- 認證到 OneLake。 相關說明請參見 「使用 PowerShell 連接 OneLake」。
請使用以下腳本,在特定路徑上列出軟刪除檔案:
# Connect to OneLake
$ctx = New-AzStorageContext -StorageAccountName "onelake" -UseConnectedAccount -endpoint "fabric.microsoft.com"
# List soft-deleted blobs in a container (workspace)
$workspaceName = "your-workspace-name"
$path = "your-lakehouse.Lakehouse/Files/"
Get-AzStorageBlob -Container $workspaceName -Context $ctx -Prefix $path -IncludeDeleted |
Where-Object { $_.IsDeleted } |
Select-Object Name, DeletedTime, RemainingDaysBeforePermanentDelete
請使用以下腳本還原軟刪除的檔案:
# Connect to OneLake
$ctx = New-AzStorageContext -StorageAccountName "onelake" -UseConnectedAccount -endpoint "fabric.microsoft.com"
# Restore a specific blob
$workspaceName = "your-workspace-name"
$blobPath = "your-lakehouse.Lakehouse/Files/deleted-file.parquet"
Get-AzStorageBlob -Container $workspaceName -Context $ctx -Blob $blobPath -IncludeDeleted |
Where-Object { $_.IsDeleted } |
Restore-AzStorageBlob
更多 PowerShell 範例,請參見 使用 PowerShell 還原已軟刪除的 Blob 和目錄。
透過使用 REST API 還原檔案
你也可以透過使用 Azure Blob Storage REST API 和 SDK 還原軟刪除的檔案。 使用“復原 Blob”操作可以恢復軟刪除 blob 的內容和元數據。
欲了解更多資訊,請參閱 「取消刪除 Blob REST API」。