Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 以编程方式删除批量中的Azure blob存储对象_Powershell_Azure_Azure Storage Blobs_Bulk - Fatal编程技术网

Powershell 以编程方式删除批量中的Azure blob存储对象

Powershell 以编程方式删除批量中的Azure blob存储对象,powershell,azure,azure-storage-blobs,bulk,Powershell,Azure,Azure Storage Blobs,Bulk,是否可以通过编程方式删除批量中的Azure blob对象? 一个接一个地删除对象有时需要几天的时间 我们在Azure Blob存储中放置了许多新文件,并删除了所有过时的文件,以避免不必要的费用 我在网上搜索了一下//StackOverflow,发现2014年MSDN上只有一个主题是关于微软网站上创建功能请求的 是否可以通过编程方式删除批量中的Azure blob对象 不需要。您需要逐个删除blob 你可以做什么来加速这个过程是创建不同的容器(比如说一个容器用于每年/每月的组合)并将相关的blob

是否可以通过编程方式删除批量中的Azure blob对象? 一个接一个地删除对象有时需要几天的时间

我们在Azure Blob存储中放置了许多新文件,并删除了所有过时的文件,以避免不必要的费用

我在网上搜索了一下//StackOverflow,发现2014年MSDN上只有一个主题是关于微软网站上创建功能请求的

是否可以通过编程方式删除批量中的Azure blob对象

不需要。您需要逐个删除blob

你可以做什么来加速这个过程是创建不同的容器(比如说一个容器用于每年/每月的组合)并将相关的blob放在其中。当您需要删除当月/年度的blob时,只需删除该容器。

当然可以(即使用Powershell)

i、 e:这将删除文档容器中的每个Powerpoint演示文稿

Get-AzureStorageBlob -Container "documents" -Context $Ctx -Blob *.pptx | Remove-AzureStorageBlob
或者,您可以删除过去30天内未更改的每个docx文件

Get-AzureStorageBlob -Container "documents" -Context $Ctx -Blob *.docx
| where {$_.LastModified -le (get-date).AddDays(-30) } | Remove-AzureStorageBlob

你可以批量删除blob。那将是一个1的电话

您所需要的只是:

  • Blob的URI列表
  • 连接到您的存储帐户
  • 从包管理器使用Azure.Storage.Blobs添加
  • 在返回中,如果删除blob时出现任何问题,异常将为您提供详细信息


    @EvertonMc您的代码所做的是列出blob,然后发送一个接一个删除blob的请求。这不是批量IMHO中的删除。对我来说,批量删除就是向Azure存储提供一个blob列表,并让它在一个请求中删除这些blob。好吧,但这真的可以扩展到批量删除,比如说3000万个文件吗?这不是一个假设性的问题。这就是我现在所看到的。
    Get-AzureStorageBlob -Container "documents" -Context $Ctx -Blob *.docx
    | where {$_.LastModified -le (get-date).AddDays(-30) } | Remove-AzureStorageBlob
    
      BlobServiceClient service = new BlobServiceClient(connectionStringForStorageAccount);
    
                BlobBatchClient batchClient = service.GetBlobBatchClient();
                try
                {
                      //dont forget to add the include snapshots :)
                   await batchClient.DeleteBlobsAsync(listofURIforBlobs,
        Azure.Storage.Blobs.Models.DeleteSnapshotsOption.IncludeSnapshots);
    
                }
                catch (Exception ex)
                {
                    return (false, ex.Message);
                }