簡體   English   中英

如何從ASP.NET Web API刪除Azure Blob?

[英]How to delete Azure blob from asp.net web api?

將圖像從我的Web api上傳到azure blob存儲可以正常工作,但是在嘗試刪除它們時卻出現以下錯誤:“ Microsoft.WindowsAzure.Storage.dll中發生了'Microsoft.WindowsAzure.Storage.StorageException類型的異常,但是用戶代碼未處理”

這是我使用的代碼:

// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));

// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

// Retrieve reference to a blob named "myblob.txt".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob.txt");

// Delete the blob.
 blockBlob.Delete();

我試圖使用的代碼來自: https : //azure.microsoft.com/sv-se/documentation/articles/storage-dotnet-how-to-use-blobs/#delete-blobs

任何幫助或輸入表示高度贊賞,謝謝!

您應該確保正確的文件名或容器名。 我同時使用這兩種方法。我確信這兩種方法都可以。

您可以在下面的行中嘗試代碼嗎?

var result= blockBlob.DeleteIfExists();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM