简体   繁体   English

尝试删除Azure Blob时找不到404

[英]Getting 404 not found when trying to delete Azure blob

I am getting a list of files hosted in Azure and attempting to delete them. 我正在获取Azure中托管的文件列表,并尝试删除它们。

var blobList = container.ListBlobs(prefix: "/2017/1/", useFlatBlobListing:true);
foreach (var blob in blobList)
{
    CloudBlockBlob blockBlob = container.GetBlockBlobReference(blob.Uri.ToString());
    blockBlob.Delete(); // This line causes a 404 not found exception.
}

When I debug and step through the code the blob.Uri matches the folder structure in Azure so not sure why this exception occurs. 当我调试并逐步执行代码时,blob.Uri与Azure中的文件夹结构匹配,因此不确定为什么会发生此异常。

Edit: Found an answer - I have to check the type and box appropriately 编辑:找到了答案-我必须适当地检查类型和复选框

foreach (var item in blobList)
{
    if (item.GetType() == typeof(CloudBlockBlob))
    {
        CloudBlockBlob blob = (CloudBlockBlob)item;
        blob.Delete();
    }
}

The op wrote: 操作员写道:

Edit: Found an answer - I have to check the type and box appropriately 编辑:找到了答案-我必须适当地检查类型和复选框

 foreach (var item in blobList) { if (item.GetType() == typeof(CloudBlockBlob)) { CloudBlockBlob blob = (CloudBlockBlob)item; blob.Delete(); } } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 删除Azure云中的Blob时远程服务器返回错误:(404)找不到 - When Delete the blob in azure cloud The remote server returned an error: (404) Not Found 尝试删除 Azure blob - 获取 blob 不存在异常 - Trying to delete an Azure blob - getting blob does not exist exception 复制Azure附加Blob获取404 - Copy Azure Append Blob getting a 404 尝试将生成的 pdf 文件上传到 Azure Blob 存储时出现 404 错误 - 404 Error when trying to upload a generated pdf file to Azure Blob Storage 尝试删除Azure Functions中的Blob但缺少DeleteIfExists方法 - Trying to delete a blob in Azure Functions but DeleteIfExists method is missing 尝试连接到blob存储时出错 - Getting error when trying to connect to blob storage 使用 Uri 下载 blob 时出现错误“404 指定的 blob 不存在” - Getting error "404 The specified blob does not exist" when downlading blob using Uri 尝试在azure存储帐户/ Blob上设置cors时出现无限错误 - Endless Errors when trying to set cors on azure storage account / Blob Azure 函数(.net core 3+) - 尝试访问 HttpRequest.Query 时出现“找不到入口点”错误 - Azure Functions(.net core 3+) - Getting “Entry point was not found” error when trying to access HttpRequest.Query 当我尝试从我的服务中删除时找不到404 - 404 not found when I try to DELETE from my service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM