[英]Use Azure Cli to Delete Old Files in Azure file share
There is an attribute for blob storage, named '--if-unmodified-since', which makes it possible to delete blobs that are older than a number of days. Blob 存储有一个名为“--if-unmodified-since”的属性,它可以删除超过几天的 Blob。 I don't find such an attribute for Files in Cli.
我在 Cli 中找不到 Files 的此类属性。 Is there a solution (with cli) for it?
有解决方案(使用cli)吗?
No Attribute similar to --if-unmodified-since
but you can leverage a logic shown below for the time being:没有类似于
--if-unmodified-since
属性,但您可以暂时利用如下所示的逻辑:
// Delete old files block
$filelist = az storage file list -s $myshare --account-name $accountName --account-key $accountKey
$fileArray = $filelist | ConvertFrom-Json
foreach ($file in $fileArray | Where-Object {$_.properties.lastModified.DateTime -lt ((Get-Date).AddDays(-90))})
{
$removefile = $file.name
if ($removefile -ne $null)
{
Write-Host "Removing file $removefile"
az storage file delete -s $myshare -p $removefile
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.