0
0
Azurecloud~5 mins

Blob storage (block, append, page) in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Blob storage lets you save large files like pictures, videos, or logs in the cloud. It offers three types of blobs: block blobs for regular files, append blobs for adding data like logs, and page blobs for random read/write like virtual disks.
When you want to store images or documents for a website using block blobs.
When you need to keep adding log entries to a file without overwriting using append blobs.
When you want to create a virtual hard drive for a virtual machine using page blobs.
When you want to upload large files in smaller pieces with block blobs.
When you need fast random access to parts of a file with page blobs.
Config File - azure-storage-blob-config.json
azure-storage-blob-config.json
{
  "storageAccountName": "examplestorage",
  "containerName": "mycontainer",
  "blobType": "BlockBlob",
  "accessTier": "Hot"
}

This JSON file sets up connection details for Azure Blob Storage.

storageAccountName: Your storage account name.

containerName: The container where blobs are stored.

blobType: Type of blob to use (BlockBlob, AppendBlob, or PageBlob).

accessTier: Storage tier for cost and performance (Hot, Cool, Archive).

Commands
Create a container named 'mycontainer' in the storage account to hold blobs.
Terminal
az storage container create --name mycontainer --account-name examplestorage
Expected OutputExpected
Created container 'mycontainer' under account 'examplestorage'.
--name - Specifies the container name.
--account-name - Specifies the storage account to use.
Upload a file as a block blob to store regular files efficiently.
Terminal
az storage blob upload --container-name mycontainer --file sample.txt --name sample-block-blob.txt --account-name examplestorage --type block
Expected OutputExpected
Upload blob 'sample-block-blob.txt' succeeded.
--container-name - Specifies the container to upload to.
--file - Local file to upload.
--type - Specifies the blob type (block here).
Add data to an append blob, useful for logs that grow over time.
Terminal
az storage blob append --container-name mycontainer --name sample-append-blob.txt --content "New log entry" --account-name examplestorage
Expected OutputExpected
Append blob 'sample-append-blob.txt' updated successfully.
--container-name - Specifies the container holding the blob.
--name - Name of the append blob.
--content - Data to append to the blob.
Upload a virtual hard disk file as a page blob for random read/write access.
Terminal
az storage blob upload --container-name mycontainer --file disk.vhd --name sample-page-blob.vhd --account-name examplestorage --type page
Expected OutputExpected
Upload blob 'sample-page-blob.vhd' succeeded.
--type - Specifies the blob type (page here).
Check details of the uploaded block blob to verify it exists.
Terminal
az storage blob show --container-name mycontainer --name sample-block-blob.txt --account-name examplestorage
Expected OutputExpected
{ "name": "sample-block-blob.txt", "container": "mycontainer", "blobType": "BlockBlob", "properties": { "contentLength": 1024, "contentType": "text/plain" } }
Key Concept

If you remember nothing else from this pattern, remember: block blobs store files, append blobs add data to logs, and page blobs support random access like virtual disks.

Common Mistakes
Uploading a large file as an append blob instead of a block blob.
Append blobs are optimized for adding data, not for large file uploads, which can cause performance issues.
Use block blobs for large files and append blobs only for data that grows by appending.
Trying to overwrite data in an append blob directly.
Append blobs only allow adding data at the end, not overwriting existing data.
To change existing data, use block blobs or page blobs instead.
Uploading a virtual hard disk file as a block blob.
Virtual hard disks require random read/write access, which block blobs do not support.
Use page blobs for virtual hard disk files.
Summary
Create a container to organize blobs in your storage account.
Upload files as block blobs for regular file storage.
Use append blobs to add data continuously, like logs.
Use page blobs for files needing random read/write access.
Verify blob uploads by checking their properties.