To follow up with the answer for anyone else: We didn't allow Trusted Microsoft Services on the Firewalls and virtual networks setup for the storage account in question. The lifecycle management counts as a trusted service so it needs that to work. Ticking that check box on there and it works.
Lifecycle mangement isn't doing anything
Every night we upload backup files to Azure Blob storage. After 7 days I would like to move these to cool storage so I made a lifecycle management rule below. This has been in place for sometime but checking today all the blobs are still in hot storage - even ones uploaded 7+ days after I added the rule. I'm not sure where to start looking to try and work out why it's not working for me?
{
"rules": [
{
"enabled": true,
"name": "move-to-cold-after-a-week",
"type": "Lifecycle",
"definition": {
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 7
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
]
}
}
}
]
}
2 additional answers
Sort by: Most helpful
-
Sumarigo-MSFT 46,126 Reputation points Microsoft Employee
2020-09-25T15:13:42.177+00:00 @Nigel Morse Can you please confirm what do you see in the portal in the rule status?
The following sample rule filters the account to run the actions on objects that exist inside container1 and start with foo.
- Tier blob to cool tier 30 days after last modification.
Syntax Example :
{
"rules": [
{
"enabled": true,
"name": "move-to-cool",
"type": "Lifecycle",
"definition": {
"actions": {
"baseBlob": {
"tierToCool": {
"daysAfterModificationGreaterThan": 30
}
}
},
"filters": {
"blobTypes": [
"blockBlob"
],
"prefixMatch": [
"mylifecyclecontainer/log"
]
}
}
}
]
}For more information about this JSON example, see the Policy and Rules sections.
Please modify the script according to your requirement. and run the script and let us know the status
#Powershell script $MaxReturn = 10000 $ContainerName = "<container name>" $Total = 0 $Token = $Null $acc = Get-AzStorageAccount -Name "<storage account name>" -ResourceGroupName "<resource group name >" do { $Blobs = Get-AzStorageBlob -context $acc.Context -Container $ContainerName -MaxCount $MaxReturn -ContinuationToken $Token $Total += $Blobs.Count if($Blobs.Length -le 0) { Break;} foreach($blob in $blobs) { If($blob.ICloudBlob.Properties.StandardBlobTier -eq "Hot") { $blob.ICloudBlob.SetStandardBlobTier("Cool") # Use $blob.ICloudBlob.SetStandardBlobTier("Archive") for archiving blobs } } $Token = $Blobs[$blobs.Count -1].ContinuationToken; } While ($Token -ne $Null) Echo "Total $Total blobs in container $ContainerName movied to Cool tier". # End of Powershell script
Hope this helps! Kindly let us know if the above helps or you need further assistance on this issue.
If the issue still persist, I would like to work closer on this issue--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.
-
Nigel Morse 191 Reputation points
2020-09-25T16:11:20.047+00:00 @Sumarigo-MSFT yes - I see exactly that. The script you show is just to move all the existing ones to cool storage right? I have manually moved a few to check that it works, but the lifecycle should be doing that for me and right now it just doesn't seem to work.