For some reasons you need to convert Azure blob files from "Archive" to "Hot" tier. You can do it, this process is rehydration.
First, we need to write a script following as below
connect-azaccount
$storageAccountName = "{yourstoragename}"
$StorageAccountKey = "{your-key}"
$storageContainer = "{your-container}"
#get context
$ctx = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $StorageAccountKey
$MaxReturn = 300
$ThrottleLimit = 100
$Token = $Null
$total = 0;
$recover = 0;
do
{
# get a list of all of the blobs in the container
$listOfBlobs = Get-AzStorageBlob -Container $storageContainer -Context $ctx -MaxCount $MaxReturn -ContinuationToken $Token -ConcurrentTaskCount 1000
if($listOfBlobs.Length -le 0) { Break;} # exit
$Token = $listOfBlobs[$listOfBlobs.Count -1].ContinuationToken;
$total = $total + $listOfBlobs.Length;
$listOfBlobs = $listOfBlobs | Where-Object {$_.ICloudBlob.Properties.StandardBlobTier -eq "Archive"}
$listOfBlobs | ForEach-Object -Parallel {
$blob = $_;
$blob.ICloudBlob.SetStandardBlobTier("Hot", "High")
} -ThrottleLimit $ThrottleLimit
$recover = $recover + $listOfBlobs.Length;
Get-Date
write-host "Recover: " $recover "Total: " $total
}while ($Null -ne $Token)
Please be noted that, you have to login to your Azure tenant via Azure CLI before doing. It would be great if you download PowerShell latest version.
Reference:
https://learn.microsoft.com/en-us/azure/storage/blobs/archive-rehydrate-overview
0 Comments
Post a Comment