且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以列出Azure Blob的上次修改日期>一些约会

更新时间:2023-02-14 22:35:12

可以使用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