Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
139 lines (131 sloc) 8.64 KB
### This code snippet is used to connect to an Azure Storage Account and tier all the blobs to Azure Archive Storage Tier.
### You need PowerShell module 4.4.0 or newer in order to be able to tier blobs to archive storage
install-module Azure -requiredVersion 4.4.0
### Import Azure PowerShell module
Import-Module Azure
### Login to your Azure Account
Login-AzureRmAccount
### Storage Account information
### In case you have several subscriptions select the proper one
Select-AzureRmSubscription (Get-AzureRMSubscription | Out-GridView -Title "Select your Azure Subscription" -PassThru)
### Select the Azure Resource Group and Storage Account
$ResourceGroupName = (Get-AzureRmResourceGroup | Out-GridView -Title "Select your Resource Group" -PassThru).ResourceGroupName
$StorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName | Out-GridView -Title "Select your Storage Account" -PassThru
$StorageAccountKey = (Get-AzureRmStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccount.StorageAccountName)[0].Value
### Create a storage context
$context = New-AzureStorageContext -StorageAccountName $StorageAccount.StorageAccountName -StorageAccountKey $StorageAccountKey
$containername = (Get-AzureStorageContainer -Context $context | Out-GridView -Title "Select your Storage Container" -PassThru).name
$blobs = Get-AzureStorageBlob -Container $containerName -Context $context
### Use the .Net client library API to change the access tier
Foreach ($blob in $blobs) {
$blob.ICloudBlob.SetStandardBlobTier("Archive")
}
# SIG # Begin signature block
# MIIT+wYJKoZIhvcNAQcCoIIT7DCCE+gCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU9dp4j+tOphpLauvrgc97Ia+j
# UPCggg72MIIEmTCCA4GgAwIBAgIPFojwOSVeY45pFDkH5jMLMA0GCSqGSIb3DQEB
# BQUAMIGVMQswCQYDVQQGEwJVUzELMAkGA1UECBMCV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AQEBBQAEggEAFZ//t+aC1xB2M/ibKm9Sj07mVpghzGee6p/2kc3KbEoj
# gXFSW5LvXrq75ITJ+QBitofCaEhhMnp17WBcZwPPrBESPZdMraUGxPP3XzZ7j4hd
# LmjO7JJ/HL6NZ2YWbQidqsJiEzq405a6hgkmPsDqaz+5ab4upC+EWWrj4sm2kNN3
# dRWubi9rWt7aeMzAzdKcbCaFRmMgRvI+woLj8SkoJOGccsslWefOe6nN98h85NGJ
# a1TbZQj8ABhlpAYaeR5KUXLLMgDzmrreFnlNDYQLgxUEzzAlt9iRh5JXoaYS0k7P
# zJ4juaG8UDP/mXMo1GDvXFJja+cvOgC+hvRw4xWaKg==
# SIG # End signature block
You can’t perform that action at this time.