[英]Retention Policy for Azure Containers?
I'm looking to set up a policy for one of my containers so it deletes or only retains data for x days. 我正在为我的一个容器设置一个策略,以便它删除或仅保留x天的数据。 So if x is 30, that container should only contain files that are less than 30 days old.
因此,如果x为30,则该容器应仅包含少于30天的文件。 If the files are sitting in the container for more than 30 days it should discard them.
如果文件在容器中放置了30天以上,则应将其丢弃。 Is there any way I can configure that?
有什么办法可以配置吗?
Currently such kind of thing is not supported by Azure Blob Storage. 当前,Azure Blob存储不支持这种事情。 You would need to write something of your own that would run periodically to do this check and delete old blobs.
您需要编写自己的某些内容,这些内容会定期运行以进行此检查并删除旧的Blob。
On a side note, this feature has been long pending (since 2011): https://feedback.azure.com/forums/217298-storage/suggestions/2474308-provide-time-to-live-feature-for-blobs . 顺便提一句,此功能早已待定(自2011年起): https : //feedback.azure.com/forums/217298-storage/suggestions/2474308-provide-time-to-live-feature-for-blobs 。
UPDATE 更新
If you need to do it yourself, there are two things to consider: 如果您需要自己执行此操作,则需要考虑两件事:
If you decide to use Azure Automation, there's a Runbook already available for you that you can use (no need to write your code). 如果您决定使用Azure自动化,则已经有一个可供您使用的Runbook(无需编写代码)。 You can find more details about this here: https://gallery.technet.microsoft.com/scriptcenter/Remove-Storage-Blobs-that-aae4b761 .
您可以在此处找到关于此的更多详细信息: https : //gallery.technet.microsoft.com/scriptcenter/Remove-Storage-Blobs-that-aae4b761 。
Azure Blob storage Lifecycle (Preview) is now available and using that we create Policies with different rules. Azure Blob存储生命周期(预览)现已可用,并使用它来创建具有不同规则的策略。
Here is the rule to delete the blobs which are older than 30 days 这是删除超过30天的Blob的规则
{
"version": "0.5",
"rules": [
{
"name": "expirationRule",
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [ "blockBlob" ]
},
"actions": {
"baseBlob": {
"delete": { "daysAfterModificationGreaterThan": 30}
}
}
}
}
]
}
For more details refer this Azure Blob storage Lifecycle 有关更多详细信息,请参考此Azure Blob存储生命周期
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.