Azure Storage Documentation

Blob Properties

Understanding the properties associated with a blob is crucial for managing its data, access, and lifecycle within Azure Blob Storage. This document details the various properties you can configure and retrieve for a blob.

Blob Metadata

Metadata is a collection of key-value pairs that you can associate with a blob. It's useful for storing custom information about the blob, such as author, creation date, or any other context relevant to your application. Metadata is not used by Azure Storage itself but is returned with blob requests.

Blob System Properties

These properties are managed by Azure Storage and provide information about the blob's state and characteristics:

Blob Access Tier

Blob storage offers different access tiers to optimize costs based on data access patterns:

You can set or change the access tier of a blob at any time.

Tip: Consider your data access patterns carefully when choosing an access tier to balance storage costs with retrieval costs and latency.

Blob Tags

Blob tags are key-value pairs that are indexed and queryable. They can be used for cost analysis, reporting, or managing access control policies based on tags. Tags are case-sensitive.

SDK Properties
REST API Properties

Accessing Blob Properties via SDK (Example: .NET)

You can retrieve blob properties using the Azure Storage SDKs. Here's a C# example:

using Azure.Storage.Blobs;
using System;

// ...

string connectionString = "YOUR_CONNECTION_STRING";
string containerName = "mycontainer";
string blobName = "myblob.txt";

BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
BlobContainerClient containerClient = blobServiceClient.GetBlobClient(containerName);
BlobClient blobClient = containerClient.GetBlobClient(blobName);

try
{
    Azure.Response<BlobProperties> propertiesResponse = await blobClient.GetPropertiesAsync();
    BlobProperties properties = propertiesResponse.Value;

    Console.WriteLine($"Blob Name: {blobName}");
    Console.WriteLine($"Content Type: {properties.ContentType}");
    Console.WriteLine($"Content Length: {properties.ContentLength} bytes");
    Console.WriteLine($"Last Modified: {properties.LastModified}");
    Console.WriteLine($"ETag: {properties.ETag}");
    Console.WriteLine($"Access Tier: {properties.AccessTier}");

    foreach (var tag in properties.Tags)
    {
        Console.WriteLine($"Tag: {tag.Key} = {tag.Value}");
    }

    foreach (var metadataEntry in properties.Metadata)
    {
        Console.WriteLine($"Metadata: {metadataEntry.Key} = {metadataEntry.Value}");
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Error retrieving blob properties: {ex.Message}");
}

Accessing Blob Properties via REST API

You can retrieve blob properties using the Get Blob Properties REST API operation. This operation returns a set of HTTP headers that include the blob's properties.

Request:

GET /<container-name>/<blob-name>?comp=properties HTTP/1.1
Host: <storage-account-name>.blob.core.windows.net
x-ms-version: 2020-08-04
Authorization: SharedKey <storage-account-name>:<signature>

Response Headers (Partial Example):

HTTP/1.1 200 OK
Content-Length: 0
Last-Modified: Tue, 25 Aug 2023 22:38:02 GMT
ETag: "0x8D546329C50A7C5"
x-ms-blob-type: BlockBlob
x-ms-access-tier: Hot
x-ms-server-encrypted: true
x-ms-lease-status: unlocked
x-ms-blob-committed-block-count: 0
x-ms-tag-header: Environment=Production&Project=AzureDocs
x-ms-blob-content-type: application/octet-stream
x-ms-blob-content-length: 102400
x-ms-blob-content-md5: null
x-ms-blob-content-encoding: null
x-ms-blob-content-language: null
x-ms-blob-cache-control: null
x-ms-blob-content-disposition: null
x-ms-copy-completion-time: null
x-ms-copy-status-description: null
x-ms-copy-status: pending
x-ms-copy-source: null
Date: Wed, 26 Aug 2023 10:00:00 GMT
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0

Managing Blob Properties

Blob properties can be managed in several ways: