如何使用 PowerShell 獲取 Azure 儲存容器中的 blob(檔案)?


要使用 PowerShell 獲取 Azure 儲存容器中的 blob,我們將使用 Get-AzStorageBlob 命令。 . 在執行此命令之前,我們需要確保 Azure 雲帳戶已連線 (Connect-AzAccount),並且設定了儲存帳戶所在的正確訂閱 (Set-AzContext)

要使用儲存帳戶,我們首先需要設定它的上下文,並且我們將使用儲存帳戶金鑰設定上下文。

$rg = "az204"
$storageaccount = "az204storage05june"
$key = (Get-AzStorageAccountKey -ResourceGroupName $rg -
Name $storageaccount)[0].Value
$context = New-AzStorageContext -StorageAccountName $storageaccount -
StorageAccountKey $key

我們現在已經建立了 Azure 儲存上下文。要獲取特定容器中的 Azure 檔案(blob),我們將使用以下命令。

Get-AzStorageBlob -Container 'container1' -Context $context

輸出

這就是從儲存容器中檢索 Azure blob 的方法。

更新於: 01-Sep-2021

1K+ 瀏覽量

開啟你的 職業生涯

透過完成課程來獲得認證

開始
廣告
© . All rights reserved.