Storage Blob Content Delivery

Overview

Azure Blob Storage provides a fast, secure, and cost‑effective way to deliver static and dynamic content to users worldwide. By exposing blobs through public endpoints or using shared access signatures (SAS), you can serve images, videos, scripts, and other assets directly from the cloud.

  • Low‑latency delivery from a global network of data centers.
  • Integration with Azure CDN for cache‑controlled, edge‑optimized performance.
  • Fine‑grained access control with SAS tokens.
  • Support for versioning and immutable blobs.

Getting Started

To make a blob publicly accessible, set its container's access level to Blob (anonymous read access for blobs only) or generate a SAS token for private containers.

Note: This is a simulated SAS token for demonstration purposes only.

Sample Code

using Azure;
using Azure.Storage.Blobs;
using Azure.Storage.Sas;

var blobServiceClient = new BlobServiceClient("");
var container = blobServiceClient.GetBlobContainerClient("mycontainer");
var blob = container.GetBlobClient("myimage.jpg");

// Generate a read‑only SAS token valid for 1 hour
BlobSasBuilder sasBuilder = new BlobSasBuilder
{
    BlobContainerName = container.Name,
    BlobName = blob.Name,
    Resource = "b",
    ExpiresOn = DateTimeOffset.UtcNow.AddHours(1)
};
sasBuilder.SetPermissions(BlobSasPermissions.Read);
string sasToken = container.GenerateSasUri(sasBuilder).Query;

Console.WriteLine($"{blob.Uri}{sasToken}");
import com.azure.storage.blob.*;
import com.azure.storage.blob.models.*;
import com.azure.storage.common.sas.*;

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
    .connectionString("")
    .buildClient();

BlobContainerClient container = blobServiceClient.getBlobContainerClient("mycontainer");
BlobClient blob = container.getBlobClient("myvideo.mp4");

// Build SAS token
BlobServiceSasSignatureValues values = new BlobServiceSasSignatureValues(
        OffsetDateTime.now().plusHours(1),
        BlobSasPermission.parse("r"))
    .setContainerName(container.getBlobContainerName())
    .setBlobName(blob.getBlobName());

String sas = blob.generateSas(values);
System.out.println(blob.getBlobUrl() + "?" + sas);
from azure.storage.blob import BlobServiceClient, generate_blob_sas, BlobSasPermissions
from datetime import datetime, timedelta

blob_service_client = BlobServiceClient.from_connection_string("")
container_client = blob_service_client.get_container_client("mycontainer")
blob_client = container_client.get_blob_client("sample.pdf")

sas_token = generate_blob_sas(
    account_name=blob_service_client.account_name,
    container_name=container_client.container_name,
    blob_name=blob_client.blob_name,
    permission=BlobSasPermissions(read=True),
    expiry=datetime.utcnow() + timedelta(hours=1)
)

print(f"{blob_client.url}?{sas_token}")
const { BlobServiceClient, generateBlobSASQueryParameters, BlobSASPermissions } = require("@azure/storage-blob");
const { v4: uuidv4 } = require("uuid");

const connStr = "";
const blobServiceClient = BlobServiceClient.fromConnectionString(connStr);
const containerClient = blobServiceClient.getContainerClient("mycontainer");
const blobClient = containerClient.getBlockBlobClient("banner.png");

// Generate SAS token (1 hour expiry)
const sasOptions = {
  containerName: containerClient.containerName,
  blobName: blobClient.name,
  permissions: BlobSASPermissions.parse("r"),
  expiresOn: new Date(new Date().valueOf() + 3600 * 1000)
};

const sasToken = generateBlobSASQueryParameters(sasOptions, blobServiceClient.credential).toString();

console.log(`${blobClient.url}?${sasToken}`);

Best Practices

  1. Use Azure CDN for high‑traffic static assets to reduce latency.
  2. Leverage cache‑control headers for resources that rarely change.
  3. Prefer immutable blobs with versioning for release assets.
  4. Secure private content with short‑lived SAS tokens.
  5. Monitor access patterns with Azure Monitor and set alerts for unusual activity.