简体   繁体   English

使用 Azure Cli 删除 Azure 文件共享中的旧文件

[英]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.

相关问题 使用 Azure Runbook 删除 Azure 文件共享中的旧文件 - Use Azure Runbook to Delete Old Files in Azure file share Azure 文件共享 - 无法从 Azure 文件共享中删除文件 - Azure file share – failed to delete files from Azure file share 如何使用 azure 逻辑应用程序、function 应用程序从 azure 存储(文件共享或 BLOB)读取、写入、删除文件 - how to use azure logic apps, function aps to read, write, delete files from an azure storage(file share or BLOB) 使用Az CLI在Azure中创建文件共享 - create file share in azure using az cli 如何在 azure-pipelines.yml 中使用 AzureCLI 删除 Azure Blob 存储上的旧文件 - How to use AzureCLI in azure-pipelines.yml to delete old files on Azure Blob Storage 如何删除azure容器中的旧文件 - how to delete old files in azure container 是否可以使用Azure Automation Runbook删除另一个Runbook输出(Azure文件共享快照)? - Is it possible to use Azure Automation Runbook to delete another Runbook output (an Azure File share snapshot)? 使用 C# 删除 Azure 文件共享快照 - Delete an Azure File Share Snapshot with C# Azure CLI - 删除订阅? - Azure CLI - delete subscription? 使用 Azure Runbook 将文件从本地计算机或网络驱动器上传到 Azure 文件共享或 Blob 存储 - Use Azure Runbook to upload files from local machine or network drive to Azure file share or blob storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM