0
0
Azurecloud~5 mins

Storage tiers (Hot, Cool, Archive) in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Storing data in the cloud can cost different amounts depending on how often you use it. Storage tiers help you save money by choosing how quickly you need to access your data. Hot tier is for data you use often, Cool tier is for data used less often, and Archive tier is for data you rarely need but want to keep.
When you have daily active files like website images or logs that need fast access, use Hot tier.
When you have backup files or older documents accessed monthly, use Cool tier to save costs.
When you want to keep data for years, like compliance records, but rarely access it, use Archive tier.
When you want to reduce storage costs by moving data automatically based on usage patterns.
When you want to balance cost and access speed for different types of data in your storage account.
Config File - storage-tier-policy.json
storage-tier-policy.json
{
  "rules": [
    {
      "name": "move-to-cool",
      "enabled": true,
      "type": "Lifecycle",
      "definition": {
        "filters": {
          "blobTypes": ["blockBlob"]
        },
        "actions": {
          "baseBlob": {
            "tierToCool": {
              "daysAfterModificationGreaterThan": 30
            }
          }
        }
      }
    },
    {
      "name": "move-to-archive",
      "enabled": true,
      "type": "Lifecycle",
      "definition": {
        "filters": {
          "blobTypes": ["blockBlob"]
        },
        "actions": {
          "baseBlob": {
            "tierToArchive": {
              "daysAfterModificationGreaterThan": 90
            }
          }
        }
      }
    }
  ]
}

This JSON file defines a lifecycle management policy for an Azure Storage account.

The first rule moves blobs to the Cool tier if they have not been modified for more than 30 days.

The second rule moves blobs to the Archive tier if they have not been modified for more than 90 days.

This helps automate cost savings by moving data to cheaper tiers based on age.

Commands
Create a new Azure Storage account with general-purpose v2 kind and locally redundant storage.
Terminal
az storage account create --name mystorageacct123 --resource-group myResourceGroup --location eastus --sku Standard_LRS --kind StorageV2
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/mystorageacct123", "location": "eastus", "name": "mystorageacct123", "resourceGroup": "myResourceGroup", "sku": { "name": "Standard_LRS" }, "kind": "StorageV2", "statusOfPrimary": "available" }
--sku - Defines the replication and performance tier
--kind - Defines the storage account type supporting tiers
Apply the lifecycle management policy from the JSON file to automate moving blobs between Hot, Cool, and Archive tiers.
Terminal
az storage account management-policy create --account-name mystorageacct123 --resource-group myResourceGroup --policy @storage-tier-policy.json
Expected OutputExpected
{ "policy": { "rules": [ { "name": "move-to-cool", "enabled": true, "type": "Lifecycle" }, { "name": "move-to-archive", "enabled": true, "type": "Lifecycle" } ] } }
--policy - Specifies the lifecycle policy JSON file
Upload a file to the storage account's container to test storage tiers.
Terminal
az storage blob upload --account-name mystorageacct123 --container-name mycontainer --name example.txt --file example.txt
Expected OutputExpected
Upload blob 'example.txt' to container 'mycontainer' successfully.
--container-name - Specifies the container to upload the blob
Check the current access tier of the uploaded blob to verify its storage tier.
Terminal
az storage blob show --account-name mystorageacct123 --container-name mycontainer --name example.txt
Expected OutputExpected
{ "name": "example.txt", "properties": { "accessTier": "Hot", "lastModified": "2024-06-01T12:00:00Z" } }
Key Concept

If you remember nothing else from this pattern, remember: choose storage tiers based on how often you need to access your data to save money.

Common Mistakes
Not enabling lifecycle management policy after creating it
Without enabling, data will not move between tiers automatically, missing cost savings.
Always apply and verify the lifecycle policy on your storage account.
Uploading blobs to a storage account that does not support tiers (like BlobStorage kind)
Some storage account kinds do not support Cool or Archive tiers, so tiering commands fail.
Use StorageV2 kind for tiering support.
Expecting immediate tier change after upload
Tier changes happen based on policy and time, not instantly after upload.
Wait for the defined days or manually change tier if needed.
Summary
Create a StorageV2 Azure Storage account to support Hot, Cool, and Archive tiers.
Define and apply a lifecycle management policy to move blobs automatically based on age.
Upload blobs and check their access tier to confirm storage tiering behavior.