如何使用 PowerShell 中的 Azure CLI 刪除 Azure Blob(檔案)?


若要使用 Azure CLI 刪除 Azure Blob,我們可以將“az storage blob”命令與“delete”引數結合使用。在執行此命令之前,我們首先需要確保 Azure 帳戶已連線(az login)且已設定正確的訂閱(az account set)

若要使用 Azure 儲存帳戶,我們需要對儲存進行身份驗證。我們可以使用儲存金鑰或儲存連線字串。我們在此說明了如何檢索連線字串。

$storageaccount = 'az204storage05june'
$connectionstring = az storage account show-connection-string -
n $storageaccount -otsv

以下命令將從儲存容器container1刪除名為‘Test1.txt’的 Azure 儲存 Blob。

az storage blob delete --account-name $storageaccount `
   --container-name 'container1' `
   --name 'Test1.txt' `
   --connection-string $connectionstring --verbose

更新時間:2021 年 9 月 1 日

4K+ 瀏覽量

開啟你的職業生涯

完成課程後獲得認證

開始
廣告