Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
465 views
in Technique[技术] by (71.8m points)

azure - Set LifeCycle Management Rule on all blobs in a container

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:windowssystem32> 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" ] } } } ]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...