c# - 是否可以列出上次修改日期 > 某个日期的 Azure Blob

标签 c# azure azure-blob-storage

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

我有一个包含数百万个 blob 的容器,并且希望将这些 blob 复制到备份容器,但不想循环遍历所有 blob,检查每个 blob 的上次修改日期。

最佳答案

可以使用 Powershell 来完成。请参阅下面的代码片段。

$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。

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

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

您还可以通过管道传输到 Sort-Object cmdlet 来排序,如下所示,对任何属性进行排序(我在下面的示例中按日期排序)。

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

关于c# - 是否可以列出上次修改日期 > 某个日期的 Azure Blob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44777851/

相关文章:

python-3.x - 无法将 Blob 存储文件复制/下载到 Azure Functions 文件夹

java - 将自定义参数添加到 Azure Blob SAS

wcf - Windows Azure 上的 Web 服务?

azure - 检查 Azure 中 Blob 副本的状态

c# - 来自httpheader的请求的ip地址

c# - 为什么 string.Split (';' ) 有效但 string.Split (':' ,StringSplitOptions.RemoveEmptyEntries) 无效?

azure - 使用 JavaScript 将文件放入 Blob 存储会导致 403(服务器无法验证请求)

c# - 错误: (412) There is currently a lease on the blob and no lease ID was specified in the request

c# - 在数据网格中显示对象列表

c# - 如何使用 .NET Compact Framework 隐藏窗体