Reputation: 45
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. I don't find such an attribute for Files in Cli. Is there a solution (with cli) for it?
Upvotes: 0
Views: 2807
Reputation: 4870
No Attribute similar to --if-unmodified-since
but you can leverage a logic shown below for the time being:
// 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
}
}
Upvotes: 2