Azure Blob SDK & Azure Cloud Services
Quick reference: Azure Blob Cheatsheet
Overview
Microsoft Azure is a cloud computing platform providing compute, storage, networking, security, identity, AI, and DevOps tooling.
Azure Blob Storage is Microsoft's scalable object storage service designed for:
- File storage
- Media hosting
- Backups
- Logging
- Data lakes
- Static websites
Blob Storage Use Cases
| Use Case | Example |
|---|---|
| File Uploads | Images, PDFs, Videos |
| Backups | System snapshots |
| Static Hosting | Frontend websites |
| Streaming | Video delivery |
| Logs | Application logging |
| Data Lakes | Big data analytics |
Azure Storage Architecture
Storage Services
| Service | Purpose |
|---|---|
| Blob Storage | Object/file storage |
| Queue Storage | Messaging |
| Table Storage | NoSQL key-value |
| File Shares | SMB file system |
Blob Types
| Blob Type | Description |
|---|---|
| Block Blob | Files/images/videos |
| Append Blob | Logging scenarios |
| Page Blob | Virtual disks |
Azure Blob Storage Hierarchy
Installing Azure Blob SDK
dotnet add package Azure.Storage.Blobs
Authentication Methods
| Method | Recommended For |
|---|---|
| Connection String | Development |
| Shared Access Signature (SAS) | Temporary access |
| Managed Identity | Production |
| Microsoft Entra ID (formerly Azure AD) | Enterprise auth |
{
"AzureStorage": {
"ConnectionString": "DefaultEndpointsProtocol=https;..."
}
}
Blob SDK Workflow
Creating BlobServiceClient
using Azure.Storage.Blobs;
var client = new BlobServiceClient(connectionString);
Dependency Injection in ASP.NET Core
builder.Services.AddSingleton(x =>
{
return new BlobServiceClient(
builder.Configuration["AzureStorage:ConnectionString"]);
});
Common Operations
Creating Containers
var containerClient = client.GetBlobContainerClient("images");
await containerClient.CreateIfNotExistsAsync();
Uploading Files
var blobClient = containerClient.GetBlobClient("photo.jpg");
await blobClient.UploadAsync(stream, overwrite: true); // without overwrite it throws if the blob exists
Downloading Files
// DownloadAsync() is obsolete; use DownloadStreamingAsync() or DownloadContentAsync()
var response = await blobClient.DownloadStreamingAsync();
return response.Value.Content;
Deleting Files
await blobClient.DeleteIfExistsAsync();
Listing Blobs
await foreach (var blob in containerClient.GetBlobsAsync())
{
Console.WriteLine(blob.Name);
}
Upload Workflow
Generating SAS Tokens
Shared Access Signatures allow temporary secure access.
var sasUri = blobClient.GenerateSasUri(
BlobSasPermissions.Read,
DateTimeOffset.UtcNow.AddHours(1));
GenerateSasUri only works when the client was built with a shared key (connection string or StorageSharedKeyCredential); check blobClient.CanGenerateSasUri. With Entra ID / Managed Identity, request a user delegation key via BlobServiceClient.GetUserDelegationKeyAsync and build the SAS with BlobSasBuilder.
Blob Metadata & Tags
await blobClient.SetMetadataAsync(new Dictionary<string, string>
{
{ "UploadedBy", "Admin" }
});
await blobClient.SetTagsAsync(new Dictionary<string, string>
{
{ "Category", "Invoice" }
});
Blob Access Tiers
| Tier | Usage |
|---|---|
| Hot | Frequently accessed |
| Cool | Infrequent access (min. 30 days) |
| Cold | Rarely accessed, still online (min. 90 days) |
| Archive | Offline, must be rehydrated before reading (min. 180 days) |
await blobClient.SetAccessTierAsync(AccessTier.Cool);
Security Best Practices
| Feature | Purpose |
|---|---|
| Managed Identity | Remove secrets |
| SAS Tokens | Limited access |
| Private Endpoints | Internal networking |
| Encryption | Protect data |
| RBAC | Fine-grained permissions |
Managed Identity (Production Recommended)
using Azure.Identity;
var client = new BlobServiceClient(
new Uri("https://mystorage.blob.core.windows.net"),
new DefaultAzureCredential());
Azure RBAC Roles
| Role | Access |
|---|---|
| Storage Blob Data Reader | Read |
| Storage Blob Data Contributor | Read/Write/Delete |
| Storage Blob Data Owner | Full data access, including ACLs on Data Lake Gen2 |
| Owner | Manages the resource (control plane); does not by itself grant blob data access with Entra ID auth |
Major Azure Cloud Services
| Service | Purpose |
|---|---|
| App Service | Web app hosting |
| Azure Functions | Serverless |
| AKS | Kubernetes |
| Azure SQL | Managed SQL |
| Cosmos DB | NoSQL database |
| Service Bus | Messaging |
| Key Vault | Secret management |
| Application Insights | Monitoring |
Azure Cloud Architecture
Deploy ASP.NET Core to Azure
az webapp up --name myapp
Deploy workflow:
Azure Functions — Blob Trigger
public static class BlobTriggerFunction
{
[FunctionName("BlobTriggerFunction")]
public static void Run(
[BlobTrigger("images/{name}")]
Stream blob)
{
}
}
Azure Service Bus
| Feature | Description |
|---|---|
| Queues | Point-to-point |
| Topics | Publish/subscribe |
| Dead Letter Queue | Failed messages |
| Retry Policies | Reliability |
Azure Key Vault
builder.Configuration.AddAzureKeyVault(
new Uri(vaultUrl),
new DefaultAzureCredential());
Application Insights
builder.Services.AddApplicationInsightsTelemetry();
Local Development with Azurite
docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite
Dockerizing ASP.NET Core + Azure SDK
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "MyApp.dll"]
Performance Optimization
| Optimization | Benefit |
|---|---|
| Async Uploads | Scalability |
| CDN | Faster delivery |
| Compression | Lower bandwidth |
| Access Tiers | Lower cost |
| Parallel Uploads | Faster transfers |
Retry Policies
var options = new BlobClientOptions
{
Retry =
{
MaxRetries = 5
}
};
Geo-Redundancy Options
| Replication | Description |
|---|---|
| LRS | Local redundancy |
| ZRS | Zone redundancy |
| GRS | Geo redundancy |
| RA-GRS | Read-access geo redundancy |
Lifecycle Management
Automatically move blobs to cheaper tiers:
Event-Driven Architecture
Common Pitfalls
| Mistake | Problem |
|---|---|
| Storing secrets in code | Security risk |
| Using account keys everywhere | Poor security |
| Missing retry policies | Reliability issues |
| No lifecycle management | High storage cost |
| Large synchronous uploads | Poor scalability |
Azure Blob SDK Cheat Sheet
| Task | Code |
|---|---|
| Create Client | new BlobServiceClient() |
| Get Container | GetBlobContainerClient() |
| Upload Blob | UploadAsync() |
| Download Blob | DownloadStreamingAsync() / DownloadContentAsync() |
| Delete Blob | DeleteIfExistsAsync() |
| Generate SAS | GenerateSasUri() |
Interview Questions
Beginner
- What is Azure Blob Storage?
- What is BlobServiceClient?
- Difference between containers and blobs?
- What are SAS tokens?
- What is Managed Identity?
Intermediate
- Explain Azure RBAC.
- Difference between Blob Storage tiers?
- How would you upload large files?
- Explain Azure Functions.
- What is Azurite?
Advanced
- How would you secure Azure Blob Storage?
- Explain Azure storage replication strategies.
- How would you design a scalable upload service?
- Explain event-driven architecture using Azure.
- How would you optimize Azure storage cost?