Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 57 ยท Storage

Storage Accounts and Blob Storage

Learn Azure storage accounts, containers, block, append and page blobs, hot, cool, cold and archive tiers, lifecycle rules, with az and SDK code and a simulator.

Almost every application stores files: images, logs, backups, exports, videos. In Azure the home for that kind of unstructured data is Blob Storage. "Blob" stands for binary large object, which is just a name for "a file of any kind". Blob Storage is cheap, huge, durable and reachable over HTTPS from anywhere, which is why it sits underneath so many other services.

You cannot use Blob Storage on its own. It lives inside a storage account, the top-level resource that holds your data and defines its location, redundancy and performance. This lesson explains the account, the blob hierarchy, the three blob types, the access tiers that control price, and lifecycle rules that move data between tiers automatically. The real commands are read-only because they need a subscription. The runnable example is a Node.js stand-in that mimics tiers and a lifecycle policy.

The storage account

A storage account is a namespace with a globally unique name (3 to 24 lowercase letters and digits). The name becomes part of the endpoint, for example https://mydata.blob.core.windows.net. One account can expose several services: Blob, Files, Queues and Tables (see Azure Files, Queues and Tables).

The settings you choose when you create it matter:

  • Performance: Standard uses hard disks and fits most workloads; Premium uses solid-state storage with low latency, with separate account kinds for block blobs, file shares and page blobs.
  • Redundancy: how many copies exist and where (LRS, ZRS, GRS and others; see Disks and Redundancy).
  • Region: where the data lives. Put it near the compute that uses it.
  • Default access tier: Hot or Cool for new blobs.

The usual choice today is a general-purpose v2 account, which supports all services and all tiers. Older general-purpose v1 and Blob-only account kinds exist but are legacy.

Terminal
# Read-only: these need an Azure subscription
az group create --name rg-data --location westeurope

az storage account create \
  --name mydata12345 \
  --resource-group rg-data \
  --location westeurope \
  --sku Standard_LRS \
  --kind StorageV2 \
  --access-tier Hot \
  --allow-blob-public-access false

Turning off public blob access is a good default. You decide later how callers are allowed in (see Storage Security and SAS Tokens).

Containers and blobs

Inside the account, Blob Storage has only two levels:

flowchart TD
    A["Storage account<br/>mydata12345"] --> B["Container<br/>photos"]
    A --> C["Container<br/>logs"]
    B --> D["Blob<br/>2025/cat.jpg"]
    B --> E["Blob<br/>2025/dog.jpg"]
    C --> F["Blob<br/>app-2025-01.log"]

A container groups blobs, like a top-level folder. Slashes in a blob name only look like folders.

A container groups blobs and carries access settings. A blob is the data plus its name, metadata and properties. The name 2025/cat.jpg is one flat string; the slash is only a naming convention, and tools show it as a virtual folder. If you enable the hierarchical namespace (used by Data Lake Storage Gen2), real directories appear, which makes rename and folder operations fast and atomic.

Uploading and listing from the CLI:

Terminal
az storage container create --account-name mydata12345 --name photos --auth-mode login

az storage blob upload \
  --account-name mydata12345 --container-name photos \
  --name 2025/cat.jpg --file ./cat.jpg --auth-mode login

az storage blob list --account-name mydata12345 --container-name photos \
  --auth-mode login --output table

--auth-mode login uses your Microsoft Entra identity instead of an account key, which is the better habit. You need a data role such as Storage Blob Data Contributor for it to work.

The same upload from JavaScript, with the SDK (read-only here, it needs a real account and the @azure/storage-blob and @azure/identity packages):

JavaScript
import { BlobServiceClient } from "@azure/storage-blob";
import { DefaultAzureCredential } from "@azure/identity";

const service = new BlobServiceClient(
  "https://mydata12345.blob.core.windows.net",
  new DefaultAzureCredential()
);
const container = service.getContainerClient("photos");
const blob = container.getBlockBlobClient("2025/cat.jpg");
await blob.uploadFile("./cat.jpg", {
  blobHTTPHeaders: { blobContentType: "image/jpeg" },
});

The three blob types

The type is chosen when a blob is created and cannot change.

Type Built from Typical use
Block blob Blocks that are uploaded separately and committed together Files, images, documents, backups, almost everything
Append blob Blocks that can only be added at the end Logs and audit trails where you never rewrite old data
Page blob 512-byte pages with random read and write Virtual machine disks (the format behind unmanaged disks)

Block blobs let large uploads run in parallel and be retried block by block; a single block blob can reach many terabytes. If you are not sure, you want a block blob.

Access tiers

Data you read every day and data you keep for seven years have different needs, so Blob Storage has access tiers. Colder tiers cost less to store and more to read.

Tier Intended for Trade-off
Hot Frequently accessed data Highest storage price, lowest access price
Cool Infrequently accessed, kept at least 30 days Cheaper storage, higher access cost, early-deletion fee under 30 days
Cold Rarely accessed, kept at least 90 days Cheaper still, early-deletion fee under 90 days
Archive Almost never accessed, kept at least 180 days Cheapest storage, but the blob is offline

Archive deserves special care. An archived blob cannot be read directly. You must rehydrate it by moving it to a hot, cool or cold tier, and that can take hours (standard priority can take up to 15 hours; high priority is faster and costs more for small blobs). Minimum retention periods and prices change, so check the current pricing page before you plan around them.

You can set a tier on a blob yourself:

Terminal
az storage blob set-tier \
  --account-name mydata12345 --container-name photos \
  --name 2025/cat.jpg --tier Cool --auth-mode login

Lifecycle management

Nobody wants to move millions of blobs by hand. A lifecycle management policy is a set of rules on the account, written in JSON. Each rule has a filter (container prefix, blob type) and actions based on age: move to Cool after 30 days, to Archive after 180, delete after 2,555 days.

JSON
{
  "rules": [
    {
      "name": "age-out-logs",
      "enabled": true,
      "type": "Lifecycle",
      "definition": {
        "filters": { "blobTypes": ["blockBlob"], "prefixMatch": ["logs/"] },
        "actions": {
          "baseBlob": {
            "tierToCool": { "daysAfterModificationGreaterThan": 30 },
            "tierToArchive": { "daysAfterModificationGreaterThan": 180 },
            "delete": { "daysAfterModificationGreaterThan": 2555 }
          }
        }
      }
    }
  ]
}
Terminal
az storage account management-policy create \
  --account-name mydata12345 --resource-group rg-data \
  --policy @policy.json

Azure evaluates these rules on a schedule (roughly once a day), so a change does not appear immediately.

A blob store with tiers and a lifecycle

The program below is a stand-in, not Azure. It keeps blobs in memory, stores a tier and a "days since modified" counter, applies a lifecycle policy as time passes, refuses to read archived blobs, and rehydrates them. The monthly prices are invented numbers chosen only to show the pattern.

Node.js Blob store with tiers and lifecycle

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The stand-in simplifies several things. Real lifecycle rules can filter by blob index tags, run on last access time instead of modification time, and act on versions and snapshots. Real rehydration takes hours, not a day tick, and Azure bills early deletion fees and tier-change operations, which this model ignores. Treat the code as a way to see the order of events, not as a price calculator.

Choosing a tier in practice

A quick comparison makes the trade-off concrete. The next stand-in uses the same invented prices to ask: for a 1,000 GB data set read a certain number of times per month, which tier gives the lowest total?

JS Which tier is cheapest to hold?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The pattern is the point: with no reads the archive tier wins, with a single read of the whole set cool wins, and from about five reads a month hot wins (cold never wins here, because its read charge is so high). Tiering saves money only when your guess about access frequency is right.

Versioning, soft delete, static websites and blob roles

The sections above cover tiers, the Archive tier and lifecycle rules. Four more blob features finish the picture.

Soft delete and versioning

Deleting by accident is the most common data loss. Two features protect against it:

  • Soft delete keeps a deleted blob (or container) for a retention period, so you can undelete it.
  • Blob versioning automatically keeps the previous state of a blob every time it is overwritten or deleted. Each version has a version ID, you can read an old one, and you can promote an earlier version by copying it over the current blob (the portal has a "make current version" action).
Terminal
az storage account blob-service-properties update \
  --account-name mydata12345 --resource-group rg-data \
  --enable-versioning true \
  --enable-delete-retention true --delete-retention-days 14 \
  --enable-container-delete-retention true --container-delete-retention-days 14

Versions are billed as stored data, so a blob that is overwritten many times grows the bill. Pair versioning with a lifecycle rule that acts on versions, for example deleting versions older than 90 days or moving them to Cool, so history does not pile up. Neither feature replaces a backup against a malicious admin; for that, see Reliability and Disaster Recovery and the immutability options.

Archive and rehydration, in practice

Archived blobs cannot be read until you rehydrate them. Two ways: change the tier of the blob back to Hot or Cool (the blob is rehydrated in place and stays unreadable until done), or copy it to a new blob in an online tier, which leaves the archived original untouched. Use standard priority for planned work and high priority when you urgently need a small blob. Make the archive step part of a design: put the date a blob might be needed in its metadata, because retrieving thousands of archived files by surprise is slow and costly.

Static website hosting

A storage account can serve a static website straight from blobs: HTML, CSS, JavaScript and images with no web server. Enabling the feature creates a special container named $web and gives the account a public endpoint such as https://<account>.z6.web.core.windows.net/, where z6 is a zone code that varies. You set an index document and an error document. For your own domain and HTTPS use a CDN or Front Door in front (see Load Balancer, Application Gateway and Front Door); the Static Web Apps project shows a managed alternative.

Terminal
az storage blob service-properties update --account-name mydata12345 \
  --static-website --index-document index.html --404-document 404.html --auth-mode login
az storage blob upload-batch --account-name mydata12345 \
  --source ./site --destination '$web' --auth-mode login

Roles for blob data

Management and data access are separate in Azure RBAC (see Role-Based Access Control). Contributor or Storage Account Contributor on the account lets you manage the account but does not automatically let you read blob contents with Entra ID; you need a data role:

Role Allows
Storage Blob Data Reader Read and list blobs and containers
Storage Blob Data Contributor Read, write and delete blobs and containers
Storage Blob Data Owner Contributor plus POSIX access control (for Data Lake)

Assign the narrowest role at the narrowest scope, for example one container, to a managed identity rather than sharing the account key (see Storage Security, Keys and Shared Access Signatures).

Versions and soft delete: a stand-in

The stand-in models a container with versioning, soft delete and restore, using an invented clock.

JS Versioning, delete and restore

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the top-level Azure resource that holds Blob, File, Queue and Table data?

    The storage account is the namespace and billing unit. Containers live inside it, and blobs live inside containers.
  2. 2. Which blob type is designed for data that is only ever added at the end, such as logs?

    Append blobs support adding blocks at the end only, which suits logs and audit trails. Block blobs are the general choice and page blobs back VM disks.
  3. 3. What must you do before reading a blob in the Archive tier?

    Archived blobs are offline. Rehydration moves them to an online tier, and standard priority can take many hours.
  4. 4. What does a lifecycle management policy do?

    Lifecycle rules are JSON on the account that tier down or delete blobs automatically, saving you from manual cleanup.
  5. 5. Why is 2025/cat.jpg not a real folder structure in a normal (flat) container?

    Without a hierarchical namespace, the container is flat. Tools split names on slashes only to display virtual folders.

Summary

  • A storage account is the top-level resource; Blob Storage inside it has containers that hold blobs.
  • Block blobs fit almost everything, append blobs fit logs, and page blobs back VM disks.
  • Hot, Cool, Cold and Archive trade storage price against access price and minimum retention; Archive is offline until rehydrated.
  • Lifecycle policies move or delete blobs automatically by age or last access.
  • Prefer Entra authentication (--auth-mode login, DefaultAzureCredential) over account keys, and disable public blob access unless you need it.

Next: Azure Files, Queues and Tables.