将图像从我的 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();
非常感谢任何帮助或意见,谢谢!
最佳答案
您应该确保正确的文件名或容器名称。 我使用这两种方法。我确信这两种方法都适用。
您可以尝试下面一行中的代码吗?
var result= blockBlob.DeleteIfExists();
关于c# - 如何从 asp.net web api 删除 Azure blob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31136723/