是否可以列出Azure Blob的上次修改日期>一些约会 [英] Is it possible to List Azure Blobs Where Last Modified Date > Some Date

查看:45
本文介绍了是否可以列出Azure Blob的上次修改日期>一些约会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以列出上次修改日期大于指定日期的容器上的所有斑点.

Is it possible to List all blobs on a container where Last Modified Date is greater than a specified date.

我有一个包含数百万个Blob的容器,想将这些Blob复制到备份容器中,但是不想遍历所有Blob,以检查每个Blob的上次修改日期.

I have a container with millions of blobs and want to copy those blobs to a backup container, however don't want to loop through all blobs checking each for Last Modified Date.

推荐答案

可以使用Powershell进行操作.请参见下面的代码段.

It is possible to do using Powershell. Please see below snippet.

$StorageAccountName = "AccountName" 
$StorageAccountKey = "What_ever_your_key_is_123asdf5524523A=="
$Context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
$ContainerName = "Container"

$Blobs = Get-AzureStorageBlob -Container $ContainerName -Context $Context `
| Where-Object{$_.LastModified.DateTime -gt (Get-Date).Date}

上述命令将从午夜开始获取当天的Blob.

Above command will get the blobs for current day from midnight.

然后可以使用 Get-Date cmdlet上的功能进一步缩小时间范围,如下所示.

You can then use the functions on Get-Date cmdlet to further narrow down the timeframe as below.

$Blobs = Get-AzureStorageBlob -Container $ContainerName -Context $Context `
| Where-Object{$_.LastModified.DateTime -gt ((Get-Date).Date).AddDays(-1)}

您还可以通过以下方式将其排序到 Sort-Object cmdlet进行排序,以对任何属性进行排序(我在下面的示例中按日期排序).

You can also sort this by piping to Sort-Object cmdlet as below to sort on any property (I sorted on date in below example).

$Blobs = Get-AzureStorageBlob -Container $ContainerName -Context $Context `
| Where-Object{$_.LastModified.DateTime -gt (Get-Date).Date.AddDays(-1)} `
| Sort-Object -Property Date

这篇关于是否可以列出Azure Blob的上次修改日期>一些约会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆