farmer
farmer copied to clipboard
Storage Account Lifecycle Policies - Versions
Hi team,
I would like to add a lifecycle policy to my storage account to delete old versions of my blobs. Is this possible with the current implementation? If so, I haven't worked it out yet.
The following
storageAccount {
name "storageAccountName"
enable_versioning [ StorageService.Blobs, true]
add_lifecycle_rule "delete-old-versions" [Storage.DeleteAfter 30<Days>] Storage.NoRuleFilters
sku Sku.Standard_GRS
}
Generates this rule:
"policy": {
"rules": [
{
"definition": {
"actions": {
"baseBlob": {
"delete": {
"daysAfterModificationGreaterThan": 30
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": []
}
},
"enabled": true,
"name": "delete-old-versions",
"type": "Lifecycle"
}
]
}
As per the Lifecycle Management Overview actions
.baseBlob
needs to be actions
.version
but I haven't spotted how this can be specified with the current API.
Thanks in advance
Hi @mike-wade . This looks like a bug then in how Farmer is rendering the ARM out. Probably the code here needs to be adjusted.
In fact it's not a bug, it's just that we don't support that feature of lifecycle policies as far as I recall. These look like the main ones we support at the moment. Probably this code needs enhancing and then following the breadcrumbs all the way down to the ARM generation. Doesn't seem like it would be too bad though.
@mike-wade I've created a branch, update-blob-lifecycle-management
for this. I now remember when I implemented this it was a simple version that intentionally didn't do everything - the hope being that someone would feedback as and when they wanted extra capabilities in it (as you did). Feel free to have a look at the branch, in particular the Adds lifecycle policies correctly
test, which shows you how the API will look like to consume. Feedback welcome.
@isaacabraham - are we going to go ahead with this enhancement? - will be happy to pick it up