I have some thousands of blobs with a given suffix I want to assign to a new tier (hot to archive) in bulk. I know it is possible to manually change the tier on portal or through a REST request pointing to a specific blob. Is there a way to set tiers in bulk with a wildcard or something similar?
Azure offers three storage tiers to store data in blob storage: Hot Access tier, Cool Access tier, and Archive tier. These tiers target data at different stages of its lifecycle and offer cost-effective storage options for different use cases.
GPv2 Storage account and Blob Storage Account type has 3 access tiers (hot,cool and archive). These account types are also called as Standard Performance Tiers. You can move data in between Hot, cold and archive.
Azure Cool Blob storage tier is intended for data that you expect to access less often than once a month, but more often than once every six months or so. The cost per gigabyte to store data in the Cool tier is significantly lower than in the Hot tier.
While a blob is in the Archive tier, it can't be read or modified. To read or download a blob in the Archive tier, you must first rehydrate it to an online tier, either Hot or Cool. Data in the Archive tier can take up to 15 hours to rehydrate, depending on the priority you specify for the rehydration operation.
It's really as simple as 3 lines.
#Get stroage account
$straccount = Get-AzureRmStorageAccount -Name xxxxxx -ResourceGroupName xxxxxxxxxxxxx
#Get all the blobs in container
$blobs = Get-AzureStorageBlob -Container test -Context $straccount.Context
#Set tier of all the blobs to Archive
$blobs.icloudblob.setstandardblobtier("Archive")
Just make sure the container only have block blob or you will get error. Last i checked Archive tier is only support by block blob.
https://docs.microsoft.com/en-us/dotnet/api/microsoft.windowsazure.storage.blob.cloudblockblob?view=azure-dotnet
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With