我已为容器配置了 azure 生命周期策略,如下所示,
{
"rules": [
{
"enabled": true,
"name": "name",
"type": "Lifecycle",
"definition": {
"actions": {
"baseBlob": {
"delete": {
"daysAfterModificationGreaterThan": 30
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"storageaccount/container"
]
}
}
}
]
}
因此它将删除 30 天之前修改的 Blob。我将备份放入容器中,因此我想删除 30 天前的旧备份。
我在 2 天前配置了此策略。但旧的备份文件不会从容器中删除
我分析了一下,按照下面的链接,新政策配置后,新政策和政策更新需要24小时才能生效
Lifecycle management policy not working on Azure Data Lake Gen 2
我也找不到很多关于这个问题的文档
我将防火墙和虚拟网络配置为“所有网络”。为什么我提到这一点是因为根据下面的文档他的解决方案有效,
但是容器中没有更新。那么有人知道这个问题的原因和解决方法吗? 谢谢!
最佳答案
请检查以下几点是否有帮助:
要检查的事项:
If version-level immutability support is enabled for a container and the container contains one or more blobs, then you must delete all blobs in the container before you can delete the container, even if there are no immutability policies in effect for the container or its blobs.
- 请检查是否 last access time tracking已启用,因为 每次访问 blob 时,它们都会移动到热层,并且可能 更改其修改时间。您需要确保您使用的是 V2 存储帐户:optionally-enable-access-time-tracking
解决方法:
使用az cli添加生命周期策略,删除容器中最近修改时间超过30天的Blob。
注意:(尝试简单地将容器名称指定为作为前缀匹配中的 blob 前缀容器名称,而不是存储帐户/容器)
例如policy.json:
"rules": [
{
"name": "expirationRule1",
"enabled": true,
"type": "Lifecycle",
"definition": {
"filters": {
"blobTypes": [ "blockBlob" ],
"prefixMatch": [ "containername" ]
},
"actions": {
"baseBlob": {
"delete": { "daysAfterModificationGreaterThan": 30 }
}
}
}
}
]
}
尝试使用 az cli command 创建此生命周期管理策略 (policy.son) :
az storage account management-policy create --account-name youraccountname --policy @policy.json --resource-group myresourcegroup
引用文献:
关于容器的 Azure 生命周期策略不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71449736/