0
votes

I am trying to set a rule which will delete all blobs in a container if they have not been modified for x number of days. I am following this link

The issue is, I am not able to find a rule which will work for all blobs in a specific container. I tried using container/ and container/* but to no effect.

Can someone guide how to achieve this? Thanks

Output of Get-AzStorageAccountManagementPolicy

PS C:\windows\system32> Get-AzStorageAccountManagementPolicy -ResourceGroupName “” -StorageAccountName “”

ResourceGroupName : “” StorageAccountName : “” Id : /subscriptions/ddd /resourceGroups/rg/providers/Microsoft.Storage/storageAccounts/storaccount/managementPolicies /default Type : Microsoft.Storage/storageAccounts/managementPolicies LastModifiedTime : 1/5/2021 10:54:21 AM Rules : [ { "Enabled": true, "Name": "allblobs", "Definition": { "Actions": { "BaseBlob": { "TierToCool": null, "TierToArchive": null, "Delete": { "DaysAfterModificationGreaterThan": 1 } }, "Snapshot": null }, "Filters": { "PrefixMatch": [ "cont1/" ], "BlobTypes": [ "blockBlob" ] } } } ]

1
The platform runs the lifecycle policy once a day. Once you configure a policy, it can take up to 24 hours for some actions to run for the first time.SumanthMarigowda-MSFT
Thanks for your reply. I noticed this but nothing happened even after a week when I set the blob to delete if it has not been modified for 2 days. Could you tell me what should be the correct syntax for all blobs under a container?Garima
if so, can you post the output of Get-AzStorageAccountManagementPolicy ?SumanthMarigowda-MSFT
For example : myaccount.blob.core.windows.net/container1/foo... for a rule, the prefixMatch is container1/foo.SumanthMarigowda-MSFT
Added the output. Yes it is container1/foo but I want to take action on all blobs inside container 1Garima

1 Answers

2
votes

If you want to delete all blobs in a container, then in the policy -> Filter set, just specify the container name only. For example, if the container name is container1, just set the Filter set as below:

enter image description here

Please also note that it may take effect after 24 hours. I did this settings before, and it worked well.