Azure Storage Accounts

Understand Azure storage accounts — Azure Tutorial.

Focus: understand azure storage accounts

Sponsored

You've spent hours configuring storage for your app — connecting to Blob, setting up databases, dealing with connection strings — and then a colleague asks, "So, what's a storage account, exactly?" You realize the answer is messier than you thought. This lesson cuts through the confusion: you'll learn what an Azure storage account is, why it's the foundation of nearly every data service in Azure, and how to choose the right one for your workload. By the end, you'll be able to creation decisions for the most common scenarios without guessing.

The Problem This Lesson Solves

Azure offers a bewildering array of storage services: Blob, Files, Queue, Table, and more. Beginners often create storage resources ad hoc, forgetting that every one of these services lives inside a storage account. Without understanding this container-based model, you'll hit walls:

  • Scattered resources — you create multiple storage accounts when one would do, paying for redundant data and management overhead.
  • Misconfigured consistency — you set the wrong replication option and later regret it when your data isn't as durable as you assumed.
  • Access headaches — you hand out connection strings instead of using managed identities, opening security holes.
  • Cost surprises — you over-provision or use the wrong tier, and your monthly bill skyrockets.

The root cause? You're thinking in terms of services (Blob, Files, etc.) instead of the account that hosts them. This lesson reframes your mental model so you can design storage from the top down.

Core Concept / Mental Model

Think of a storage account as a master container or a lease that gives you access to Azure's underlying storage fabric. It's not a physical drive; it's a logical grouping that defines:

  • Where your data lives (the Azure region).
  • How it's replicated (durability and availability).
  • Who can access it (authentication and authorization).
  • What services you can use (Blob, Files, Queue, Table, and more).

Visualize it as an apartment building:

  • The storage account is the building itself.
  • The services (Blob, Files, Tables, Queues) are the apartments.
  • The connection string or SAS token is the key to the building's front door.
  • The region and replication are the building's location and structural integrity (does it survive a fire?).

Every storage account must have a globally unique name (3–24 characters, lowercase, numbers, and hyphens), and it defines the endpoint for each service: you get https://<account>.blob.core.windows.net, https://<account>.file.core.windows.net, and so on.

Pro tip: A single storage account can host Blob containers, file shares, queues, and tables simultaneously. You don't need a separate account for each service — design for consolidation first.

How It Works Step by Step

Creating and using a storage account follows a predictable sequence:

  1. Plan — Decide on the storage type (general-purpose v2 is the default for most workloads), region, and performance tier (Standard or Premium).
  2. Create — Provision the account via the portal, Azure CLI, PowerShell, or Infrastructure-as-Code (Bicep/Terraform).
  3. Configure replication — Choose among LRS, ZRS, GRS, or GZRS based on your durability needs.
  4. Secure access — Prefer managed identities or SAS tokens over shared keys. Use Azure AD for role-based access control (RBAC).
  5. Use the services — Create containers, file shares, queues, and tables within the account.
  6. Monitor and manage — Set up alerts for throttling, costs, and errors.

Key components inside the account

  • Containers (for Blob storage) — a flat namespace for blobs; you create containers to organize data.
  • File shares — SMB or NFS file shares for legacy app lift-and-shift.
  • Queues — for decoupling components and building message-driven workflows.
  • Tables — NoSQL key-value storage for structured data at scale.
  • Disks (page blobs) — used by Azure VMs for OS and data disks (not directly accessed via the API).

The Azure Storage API surface

All services share a common REST API, authenticated via shared key, SAS, or Azure AD. Here's a minimal diagram in words:

Storage Account: mystorageaccount
  ├── Blob Service   → https://mystorageaccount.blob.core.windows.net
  │     └── Container: mycontainer → blobs (images, logs)
  ├── File Service   → https://mystorageaccount.file.core.windows.net
  │     └── Share: myshare → file paths
  ├── Queue Service  → https://mystorageaccount.queue.core.windows.net
  │     └── Queue: myqueue → messages
  └── Table Service  → https://mystorageaccount.table.core.windows.net
        └── Table: mytable → entities

This model is the key to understanding: you manage the account, not the individual services — routing, throttling, and monitoring happen at the account level.

Hands-On Walkthrough

Let's create a storage account and interact with Blob storage using the Azure CLI and the Python SDK. This exercise solidifies the mental model.

Prerequisites

  • Azure subscription (free account works)
  • Azure CLI installed and logged in (az login)
  • Python 3.10+ with pip install azure-storage-blob

Step 1: Create a resource group and storage account

# Variable names (must be globally unique)
RESOURCE_GROUP="my-rg"
STORAGE_ACCOUNT="mystorageacc"
LOCATION="eastus"

# Create a resource group for this lesson
az group create --name $RESOURCE_GROUP --location $LOCATION

# Create a general-purpose v2 storage account with LRS replication
az storage account create \
  --name $STORAGE_ACCOUNT \
  --resource-group $RESOURCE_GROUP \
  --location $LOCATION \
  --kind StorageV2 \
  --sku Standard_LRS

📝 Expected output: A JSON blob with "provisioningState": "Succeeded" and your endpoints.

Step 2: Create a Blob container

# Create a container named "logs"
az storage container create \
  --name logs \
  --account-name $STORAGE_ACCOUNT \
  --auth-mode login

Note: Using --auth-mode login ensures your Azure AD identity authenticates — not a shared key. This is the modern, secure way.

Step 3: Upload a blob via Python

Now let's write Python to upload a file and list blobs.

from azure.azure_storage.blob import BlobServiceClient, ContainerClient
import os

# From Azure CLI: az storage account show-connection-string --name YOUR_ACCOUNT --resource-group YOUR_RG
CONN_STR = os.getenv("AZURE_STORAGE_CONNECTION_STRING")

# Create a blob service client
blob_service = BlobServiceClient.from_connection_string(CONN_STR)

# Get the container (must already exist)
container_client = blob_service.get_container_client("logs")

# Create a local sample file
with open("sample.log", "w") as f:
    f.write("INFO: Hello, storage account!\n")

# Upload the file as a blob
with open("sample.log", "rb") as data:
    blob_client = container_client.upload_blob("sample.log", data, overwrite=True)

# List blobs in the container
print("Listing blobs:")
for blob in container_client.list_blobs():
    print(f"  {blob.name} ({blob.size} bytes)")

Expected output:

Listing blobs:
  sample.log (32 bytes)

Step 4: Download and verify

# Download the blob to a new file
blob_client = container_client.get_blob_client("sample.log")
with open("downloaded.log", "wb") as f:
    f.write(blob_client.download_blob().readall())

print(open("downloaded.log").read())

That's the full lifecycle: create account → create container → upload → download. You now understand that the storage account is the parent that makes Blob storage available.

Compare Options / When to Choose What

You have choices for kind, performance, and replication. Here's how to decide.

Storage account kinds

Kind Services Best for
StorageV2 (general-purpose v2) Blob, Files, Queue, Table, Data Lake Modern workloads, most APIs, lowest cost per GB
BlobStorage Blob only Legacy blob-only scenarios, lifecycle management
FileStorage Files only (Premium) High-throughput SMB/NFS file shares
BlockBlobStorage Blob only (Premium) Consistent low-latency blob workloads

Choose StorageV2 unless you have a very specific need (e.g., premium file-only).

Performance tiers

  • Standard — magnetic disk, lower cost, multiple replication options.
  • Premium — SSD-backed, low latency, but higher cost; best for high IOPS needs.

Replication strategies

Option Durability Availability Cost Use case
LRS 99.999999999% (11 nines) Single data center Lowest Dev/test, non-critical data
ZRS 11 nines Across 3 availability zones Medium Regional failover within a region
GRS 16 nines Regional failover to secondary region Higher Disaster recovery across regions
GZRS 16 nines Zone-redundant + regional failover Highest Maximum resilience

Pro tip: Start with LRS for learning, but switch to ZRS or GZRS when data is production-critical. The default is LRS for cost reasons, but it does not survive a data-center outage.

Access control: shared keys vs SAS vs managed identity

Method Credential type Security Use when
Shared key Account key Weak — full access Legacy, quick prototyping
SAS token Time-limited Moderate — scoped Third-party uploads, temporary access
Azure AD + RBAC Identity / principal Strongest — no secrets Production, anywhere possible

Always prefer Azure AD authentication. You used it in the CLI via --auth-mode login; in Python, use DefaultAzureCredential from azure-identity instead of connection strings for real projects.

Troubleshooting & Edge Cases

Common errors and how to fix them:

"The storage account name 'x' is not available"

  • Cause: The name violates the global uniqueness rule or the 3–24 character limit.
  • Fix: Use lowercase letters, numbers, and hyphens only. Try a more unique suffix like mystorageaccount2025.

"Container name must be lowercase"

  • Cause: You used uppercase or a - in the container name.
  • Fix: Containers must be lowercase and can only use letters, numbers, and hyphens (≤ 63 chars).

"AuthorizationPermissionMismatch" error

  • Cause: Your Azure AD role doesn't have Storage Blob Data Contributor on the container.
  • Fix: Assign RBAC role via:
az role assignment create --assignee <your-user> --role "Storage Blob Data Contributor" --scope "/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Storage/storageAccounts/<account>"

"The request is being throttled" (HTTP 503)

  • Cause: You hit the per-account request/s or bandwidth limit.
  • Fix: Scale out by using multiple containers or partitions, or upgrade to Premium. Also check whether you're accidentally using a List Blobs call in a tight loop.

Edge case: Data Lake Storage Gen2

If you need hierarchical namespaces for analytics, enable the hierarchical namespace feature when creating a StorageV2 account — it converts the blob namespace to a folder hierarchy. This cannot be changed later without recreating the account.

What You Learned & What's Next

You now understand that a storage account is the foundational container for all Azure data services. You know:

  • The core concept: a logical grouping for Blob, Files, Queue, Table, and disks.
  • How to create a general-purpose v2 account with proper naming, region, and replication.
  • How to use it hands-on — creating containers, uploading/downloading blobs via Python.
  • Which options to choose — kind, performance, replication, and access method, depending on your scenario.
  • How to troubleshoot common naming, auth, and throttling errors.

Next step: In the next lesson, you'll connect a storage account to a virtual network and restrict access using service endpoints — a key step for securing your data from the internet. You'll apply the same mental model of the account as the boundary, but now you'll configure the network perimeter.

Now that you understand the storage account, you're ready to build storage-backed applications with confidence. Go create your first storage account and make a blob — you've earned it!

Practice recap

To solidify this lesson, create a second container in the same storage account and upload a file via Python. Then, try deleting the storage account (after cleaning up resources) to see how the container hierarchy is removed. Finally, assign RBAC roles to a service principal instead of using connection strings — confirm your Python code works with DefaultAzureCredential.

Common mistakes

  • Creating a new storage account for every service — one storage account can host Blob, Files, Queue, and Table simultaneously, so consolidate to save cost and management overhead.
  • Using the account key (shared key) for authentication in production — use managed identities or, if you must, SAS tokens with short expiry; shared keys give full access and can be leaked.
  • Choosing LRS for critical production data thinking it's sufficient — LRS does not survive a data-center-wide outage; opt for ZRS or GZRS when durability matters.
  • Forgetting that container names must be lowercase and can't contain hyphens — you'll get a 'Container name must be lowercase' error and waste time debugging.

Variations

  1. Use Azure PowerShell instead of CLI: New-AzStorageAccount -ResourceGroupName ... -Name ... -SkuName Standard_LRS -Kind StorageV2.
  2. Provision infrastructure as code with Bicep or Terraform — define the storage account and its services in declarative files for reproducible environments.
  3. Alternatively, manage storage entirely via the Azure portal, which is great for one-off demos but slower to automate.

Real-world use cases

  • Storing user-uploaded profile images in a Blob container within a single storage account, with SAS tokens for read access.
  • Sharing large files across teams using Azure Files — a storage account hosts an SMB file share that multiple VMs mount simultaneously.
  • Building a decoupled microservices architecture with Azure Queues — a storage account hosts the queue, and workers poll for messages with managed identity.

Key takeaways

  • A storage account is a master container that hosts Blob, Files, Queue, Table, and disk services — consolidate services within one account.
  • The storage account name is globally unique and must be 3–24 lowercase letters/numbers/hyphens; choose it carefully.
  • Choose the right replication: LRS for dev/test, ZRS for zone protection, GRS/GZRS for regional disaster recovery.
  • Prefer Azure AD (managed identity) or SAS tokens over shared keys for secure access to storage.
  • Troubleshooting storage issues starts with checking names, RBAC roles, and throttling limits at the account level.
  • Each service (Blob, Files, etc.) has its own endpoint rooted at https://<account>.service.core.windows.net.

Sponsored

Sponsored

Discussion

Questions, corrections, and tips help everyone reading this page.

0 comments

Add a comment

Shown publicly with your comment.

Be constructive · max 4,000 characters

No comments yet — start the thread.

Related tutorials, quizzes, and articles for this topic.