Storage accounts, containers, files
| Level | Example | Notes |
|---|---|---|
| Storage account | stshopkartdev | Globally unique name, 3–24 lowercase letters/numbers; region, redundancy, HNS on/off |
| Container (file system) | lake | Top-level folder; access can be set here |
| Directories + files | raw/orders/2026/10/01/orders_2026-10-01.csv | Real directories only with HNS (ADLS Gen2) |
lake/ ├── raw/ data exactly as it arrived (bronze) │ └── orders/2026/10/01/orders_2026-10-01.csv ├── curated/ cleaned, typed, de-duplicated (silver/gold) │ └── daily_revenue/daily_revenue.parquet └── archive/ old raw data on a cool tier
Try it locally with Azurite
Azurite is Microsoft's official Azure Storage emulator. The Python code is the same you'd use against Azure; only the connection string changes.
$npm install azurite && npx azurite-blob --location ./azurite-data$pip install azure-storage-blob pandas pyarrow
from azure.storage.blob import BlobServiceClient
# Azurite's well-known local development account (published by Microsoft; never use it in Azure)
CONN = ("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;"
"AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;"
"BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;")
service = BlobServiceClient.from_connection_string(CONN)
lake = service.create_container("lake")
print("container:", lake.container_name)container: lakeUpload into dated folders
import glob, os
for path in sorted(glob.glob("../pyspark/data/orders/orders_2026-10-0[1-3].csv")):
day = os.path.basename(path)[7:17] # 2026-10-01
blob_name = f"raw/orders/{day.replace('-', '/')}/{os.path.basename(path)}"
with open(path, "rb") as f:
lake.upload_blob(blob_name, f, overwrite=True,
metadata={"source": "shopkart-app", "load_date": day})
print("uploaded", blob_name)uploaded raw/orders/2026/10/01/orders_2026-10-01.csv
uploaded raw/orders/2026/10/02/orders_2026-10-02.csv
uploaded raw/orders/2026/10/03/orders_2026-10-03.csv# Blob storage is flat: "folders" are just prefixes in the name
for b in lake.list_blobs(name_starts_with="raw/orders/2026/10/"):
print(f"{b.name:<45} {b.size:>6} bytes tier={b.blob_tier}")
print([p.name for p in lake.walk_blobs(name_starts_with="raw/orders/2026/10/", delimiter="/")])raw/orders/2026/10/01/orders_2026-10-01.csv 4548 bytes tier=Hot
raw/orders/2026/10/02/orders_2026-10-02.csv 5402 bytes tier=Hot
raw/orders/2026/10/03/orders_2026-10-03.csv 4226 bytes tier=Hot
['raw/orders/2026/10/01/', 'raw/orders/2026/10/02/', 'raw/orders/2026/10/03/']In Blob storage those “folders” are just prefixes in each blob's name; walk_blobs with a / delimiter groups them. With ADLS Gen2 they're real directories, which is why renaming or deleting a folder is one fast operation there instead of copying every file.
props = lake.get_blob_client("raw/orders/2026/10/01/orders_2026-10-01.csv").get_blob_properties()
print(props.metadata, props.content_settings.content_type, props.etag){'source': 'shopkart-app', 'load_date': '2026-10-01'} application/octet-stream "0x264614E5C431A80"Metadata travels with each file (useful for lineage). Note the content type defaulted to application/octet-stream: pass ContentSettings(content_type="text/csv") when it matters.
Read, transform, write Parquet
import io, pandas as pd
frames = []
for b in lake.list_blobs(name_starts_with="raw/orders/"):
data = lake.download_blob(b.name).readall()
frames.append(pd.read_csv(io.BytesIO(data)))
orders = pd.concat(frames)
delivered = orders[orders.status == "DELIVERED"]
summary = (delivered.assign(day=delivered.order_ts.str[:10],
amount=delivered.quantity * delivered.unit_price)
.groupby("day").agg(orders=("order_id", "count"), revenue=("amount", "sum")).reset_index())
print(summary)
buf = io.BytesIO(); summary.to_parquet(buf, index=False)
lake.upload_blob("curated/daily_revenue/daily_revenue.parquet", buf.getvalue(), overwrite=True)
print("wrote curated/daily_revenue/daily_revenue.parquet,", len(buf.getvalue()), "bytes") day orders revenue
0 2026-10-01 60 161518
1 2026-10-02 75 150211
2 2026-10-03 65 137518
wrote curated/daily_revenue/daily_revenue.parquet, 2299 bytesSame daily totals as our PySpark streaming lesson. Small files are fine with pandas; for gigabytes you'd read the same paths with Spark (abfss://[email protected]/raw/orders/) on Databricks or Fabric.
Access tiers and redundancy
blob = lake.get_blob_client("raw/orders/2026/10/01/orders_2026-10-01.csv")
blob.set_standard_blob_tier("Cool") # older raw files: cheaper storage
print(blob.get_blob_properties().blob_tier)Cool| Tier | Storage cost | Read cost | Use for |
|---|---|---|---|
| Hot | Highest | Lowest | Recent and frequently used data |
| Cool | Lower | Higher | Older raw files (30+ days minimum) |
| Cold | Lower still | Higher still | Rarely read (90+ days minimum) |
| Archive | Lowest | Highest; offline, hours to rehydrate | Compliance copies (180+ days) |
| Redundancy | Copies | Protects against |
|---|---|---|
| LRS | 3 in one datacenter | Disk/server failure (cheapest, dev) |
| ZRS | 3 across availability zones | A datacenter outage (common for prod) |
| GRS / GZRS | Plus a copy in a paired region | A whole region outage |
The ADLS Gen2 API (on real Azure)
Azurite doesn't emulate the dfs endpoint, so this part follows Microsoft's SDK documentation:
# Real ADLS Gen2 (not run here: needs an Azure storage account and an Entra ID sign-in)
from azure.identity import DefaultAzureCredential
from azure.storage.filedatalake import DataLakeServiceClient
lake = DataLakeServiceClient("https://stshopkartdev.dfs.core.windows.net",
credential=DefaultAzureCredential()) # no keys: your identity (lesson 3)
fs = lake.get_file_system_client("lake")
fs.get_directory_client("raw/orders/2026/10").rename_directory("lake/archive/orders/2026/10") # one fast, atomic call🎯 Interview questions on this topic
Try to answer out loud first, then tap to check.
Q1What is the difference between Blob Storage and ADLS Gen2?Fresher
Q2How do you organise a data lake?1–3 yrs
Q3How do you reduce storage costs?1–3 yrs
Q4Why does hierarchical namespace matter for Spark jobs?3+ yrs
Key takeaways
- Turn on hierarchical namespace for any data lake.
- Lay out folders by zone, source and date.
- Tiers and redundancy are your main cost levers.
- Azurite lets you practise storage code for free.
Frequently asked questions
What is ADLS Gen2?
Azure Data Lake Storage Gen2 is Azure Blob Storage with the hierarchical namespace turned on. You get real directories (fast, atomic renames and deletes), POSIX-style ACLs on folders and files, and the dfs endpoint that Spark and Databricks use with abfss:// paths, while keeping blob storage prices and tiers.
Blob storage or ADLS Gen2 for a data lake?
ADLS Gen2. Analytics engines rename and delete whole folders constantly (for example when a Spark job commits output); with a flat namespace that means copying every file. Turn on hierarchical namespace when you create the account; it can't simply be switched back off.
What is Azurite?
Microsoft's free, open-source emulator for Azure Storage (Blob, Queue, Table) that runs on your laptop. Code written with the Azure SDK works against it with a connection string change. It doesn't emulate the ADLS Gen2 dfs endpoint.
Which access tier should I use?
Hot for data read often (recent raw and curated data), Cool for data read rarely (older raw files, 30+ days), Cold for very rarely read (90+ days), Archive for compliance copies you almost never need (hours to rehydrate). Lifecycle management rules move files automatically by age.
🧠 Quick check: ADLS Gen2
1. What makes a storage account an ADLS Gen2 data lake?
2. In plain Blob storage, 'raw/orders/2026/10/' is...
3. Old raw files are read once a quarter. Tier?
4. Spark reads ADLS Gen2 with paths like...