📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

Azure has Blob Storage, Queue Storage, Service Bus, Event Grid and Event Hubs. What is each one for, how do they differ in delivery, ordering, size limits and retention, and how do you pick the right one for files, commands, notifications and telemetry streams?

Comparing Azure Blob Storage, Queue Storage, Service Bus, Event Grid and Event Hubs by purpose, delivery guarantee, ordering, message size and retention, with a decision guide for .NET teams.

Intermediate Theory Intermediate azure blob-storage devops event-grid event-hubs service-bus

🎯 Key points

  • Blob Storage stores objects (files), with hot, cool, cold and archive tiers
  • Queue Storage: simple at-least-once queue, 64 KiB messages, no ordering and no built-in dead-letter queue (Functions moves failures to a -poison queue)
  • Service Bus: broker for commands and business events with topics, sessions, DLQ, duplicate detection; 256 KB Standard, up to 100 MB Premium
  • Event Grid: push-based routing of discrete events, retries for up to 24 hours, dead-lettering only if configured
  • Event Hubs: partitioned stream ingestion, consumer groups, checkpoints, Kafka endpoint
  • All are at-least-once, so consumers deduplicate
  • Cost models differ: per operation (Queue Storage, Service Bus Standard, Event Grid) vs reserved capacity (Service Bus Premium messaging units, Event Hubs throughput or processing units)
  • Choose by intent: message (someone must act) vs event (something happened) vs stream (many readings)

⏱ 30-second answer

They solve different problems:

  • Blob Storage stores files and large payloads; it is not a messaging service.
  • Queue Storage is a cheap, simple queue (64 KiB messages, no ordering, no dead-letter queue).
  • Service Bus is the enterprise broker for commands and business messages: queues, topics, sessions for ordering, dead-lettering, duplicate detection, transactions.
  • Event Grid pushes discrete events ("a blob was created", "an order shipped") to subscribers, with retries.
  • Event Hubs ingests streams of millions of events into partitions that consumers read at their own pace.

All of them deliver at least once, so consumers must deduplicate. The trade-off is features versus cost and throughput: Service Bus gives the richest guarantees, Event Hubs the highest throughput, Queue Storage the lowest price.

🗣 Full answer (senior)

How I would answer this in an interview

"I start with the intent of the data. If it's a file, it goes in Blob Storage, and if I need to tell someone about it, I send a small message or event that points to the blob, because brokers have size limits. If it's a message, meaning someone must act on it, like 'charge this order', I use Service Bus. It gives me peek-lock delivery, dead-letter queues, sessions for ordering per key, scheduled messages, duplicate detection and transactions. Queue Storage is the budget option for simple background work where I don't need any of that: 64 KiB messages, a visibility timeout and a dequeue count, and that's it.

If it's an event, meaning 'something happened, react if you care', I use Event Grid. It pushes events to webhooks, Functions, Service Bus or Event Hubs, filters by type or subject, and retries with back-off for up to 24 hours before dead-lettering to a blob. Many Azure services publish to it natively, such as Blob Storage raising BlobCreated. If it's a stream, like telemetry from thousands of devices or clickstream data, I use Event Hubs. Events go into partitions, are kept for a retention period, and each consumer group reads at its own offset and checkpoints. It also exposes a Kafka endpoint, so Kafka clients work unchanged.

Whatever I pick, delivery is at-least-once, so the consumer deduplicates on a message id or business key. The mistake I see is using Event Hubs as a job queue or Service Bus as a telemetry firehose. Choose by intent first, then check limits and price."


Side by side

Queue Storage Service Bus Event Grid Event Hubs
Model Queue Queues and topics (pull) Push routing (also pull on namespace topics) Partitioned log (pull)
Delivery At-least-once At-least-once (peek-lock) or at-most-once (receive-and-delete) At-least-once, retries up to 24 h At-least-once from last checkpoint
Ordering None FIFO per session None Per partition
Max message 64 KiB 256 KB Standard, up to 100 MB Premium 1 MB 1 MB
Retention Up to TTL (default 7 days, can be unlimited) Until consumed or TTL Until delivered or dead-lettered Time-based: up to 7 days Standard, 90 days Premium/Dedicated
Dead-lettering No (Functions moves to -poison queue) Built-in DLQ To a blob container No; consumer handles it
Best for Simple background jobs Commands, workflows, business events Reacting to state changes Telemetry, logs, high-volume streams

Duplicates: what the consumer does

Service Why duplicates happen Consumer strategy
Queue Storage Visibility timeout expires before delete Idempotent handler, track processed ids
Service Bus Lock expires or handler crashes before Complete Dedupe on MessageId in the same DB transaction (inbox)
Event Grid Subscriber didn't return 2xx in time Dedupe on event id
Event Hubs Restart replays from last checkpoint Idempotent writes (upsert by key)

Production example

A logistics platform used Blob Storage for proof-of-delivery photos, Event Grid BlobCreated events to trigger thumbnail generation, Service Bus topics for order commands between services, and Event Hubs for GPS pings from [4,000] trucks every 10 seconds, about 400 events per second. Putting the GPS stream on Service Bus had earlier cost roughly three times as much and hit throttling at peak.

🔍 What the interviewer is checking

Checks that the candidate can choose a messaging or storage service by intent and knows the key limits and guarantees.

Green flags

  • Separates messages, events and streams
  • Knows Service Bus features (sessions, DLQ, duplicate detection) and Event Hubs partitions and checkpoints
  • Uses the claim-check pattern for large payloads
  • States at-least-once delivery and how the consumer deduplicates

Red flags

  • Treats all five as interchangeable
  • Believes any of them is exactly-once
  • Puts files in messages

📚 Learn in depth

1. Messages, events and streams

Message (command):  OrderService ── "ChargeOrder 123" ──▶ [queue] ──▶ PaymentService (must act)
Event (fact):       Storage ── "BlobCreated x.pdf" ──▶ Event Grid ──▶ 0..n subscribers (may react)
Stream (series):    Devices ── readings ──▶ Event Hubs [p0][p1][p2]... ──▶ consumer groups read at own offsets

A message carries an expectation that a specific consumer acts; losing it is a business problem. An event reports a fact; the publisher does not care who listens. A stream is a sequence where the value is often in aggregate and replay.

2. How Service Bus delivers

Peek-lock: the broker locks the message for the lock duration (default 60 seconds, maximum 5 minutes), the consumer processes it and calls Complete. If the consumer crashes or the lock expires, the message becomes visible again and DeliveryCount goes up. After MaxDeliveryCount (default 10) it moves to the dead-letter queue. Sessions lock all messages with the same SessionId to one consumer, which gives FIFO per key. Duplicate detection drops messages with a repeated MessageId inside a configured window, which protects against publisher retries but not consumer redelivery.

3. How Event Grid delivers

Event Grid pushes an HTTP POST to each subscription. A 2xx response is success. Otherwise it retries with exponential back-off for up to 24 hours or 30 attempts (both configurable lower), then dead-letters to a blob container if configured. Webhook endpoints must pass a validation handshake. Events use the Event Grid schema or CloudEvents 1.0.

4. How Event Hubs delivers

Producer ── partition key "truck-17" ──▶ hash ──▶ partition 3 ── offset 1,204,551
Consumer group "analytics": EventProcessorClient owns partition 3, checkpoints offset to Blob Storage

Events are appended to partitions and kept for the retention period whether read or not. EventProcessorClient balances partitions across instances and stores checkpoints in Blob Storage. After a restart, it resumes from the last checkpoint, so events after it are delivered again. Throughput is bought in throughput units (Standard) or processing units (Premium).

5. Queue Storage internals

ReceiveMessages hides a message for the visibility timeout and returns a pop receipt. DeleteMessage with that receipt removes it. If the timeout passes first, it reappears with a higher dequeue count. There is no broker-side dead-lettering; the Functions Queue trigger moves a message to <queue>-poison after 5 dequeues. A single queue targets about 2,000 messages per second.

Try it yourself

  1. Send 10 messages to a Service Bus queue, throw on the first delivery of each, and watch DeliveryCount and the DLQ in Service Bus Explorer.
  2. Create an Event Grid subscription from a storage account to an Azure Function and upload a blob.
  3. Send 10,000 events to Event Hubs with partition keys, then read them with two EventProcessorClient instances and watch partition ownership move.
  4. Put a 70 KiB message on Queue Storage and read the error.

💻 Code

A blob upload raises an Event Grid event; the API sends a Service Bus command that references the blob instead of carrying the file. All clients use managed identity.

namespace Documents.Api;

using Azure.Identity;
using Azure.Messaging.ServiceBus;
using Azure.Storage.Blobs;
using Microsoft.Extensions.Azure;

public sealed record ProcessDocument(Guid DocumentId, string BlobName);

public static class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        builder.Services.AddAzureClients(c =>
        {
            c.AddBlobServiceClient(new Uri(builder.Configuration["Storage:BlobUri"]!));
            c.AddServiceBusClientWithNamespace(builder.Configuration["ServiceBus:Namespace"]!);
            c.UseCredential(new DefaultAzureCredential());
        });
        builder.Services.AddSingleton(sp =>
            sp.GetRequiredService<ServiceBusClient>().CreateSender("process-document"));

        var app = builder.Build();

        app.MapPost("/documents", async (IFormFile file, BlobServiceClient blobs,
            ServiceBusSender sender, CancellationToken ct) =>
        {
            var id = Guid.NewGuid();
            var blobName = $"{id}/{file.FileName}";

            // 1. The file goes to Blob Storage: brokers have small size limits.
            await blobs.GetBlobContainerClient("incoming")
                .UploadBlobAsync(blobName, file.OpenReadStream(), ct);

            // 2. A small command points to it. MessageId = document id, so Service Bus
            //    duplicate detection drops a retried send, and the consumer can dedupe on it.
            var message = new ServiceBusMessage(BinaryData.FromObjectAsJson(new ProcessDocument(id, blobName)))
            {
                MessageId = id.ToString(),
                ContentType = "application/json"
            };
            await sender.SendMessageAsync(message, ct);

            return Results.Accepted($"/documents/{id}");
        }).DisableAntiforgery();

        app.Run();
    }
}

⚠ Common mistakes

  • Mistake: Putting files or large JSON payloads inside messages. Why it is wrong: Service Bus Standard caps at 256 KB (Premium up to 100 MB), Event Grid and Event Hubs at 1 MB, Queue Storage at 64 KiB. Instead: Store the payload in Blob Storage and send a reference (the claim-check pattern).
  • Mistake: Using Event Hubs as a work queue. Why it is wrong: There is no per-message completion, lock or dead-lettering; one bad event blocks a partition's checkpoint. Instead: Use Service Bus for work items and Event Hubs for streams.
  • Mistake: Using Event Grid for commands that must be processed, without dead-lettering configured. Why it is wrong: Dead-lettering is opt-in; by default, after 24 hours (or 30 attempts) of failed retries the event is simply dropped. Instead: Configure a dead-letter blob container and alert on it, or route important events into a Service Bus queue and process them from there.
  • Mistake: Assuming Service Bus duplicate detection makes processing exactly-once. Why it is wrong: It only drops repeated sends with the same MessageId inside the configured detection window (up to 7 days); redelivery after a lock timeout still happens. Instead: Make the consumer idempotent.
  • Mistake: Choosing Queue Storage and then building dead-lettering, ordering and topics by hand. Why it is wrong: You recreate Service Bus badly. Instead: Pay for Service Bus when you need its features.
  • Mistake: Expecting global ordering from any of them. Why it is wrong: Ordering is per session or per partition at best. Instead: Choose a session or partition key per aggregate and design for out-of-order arrival.
  • Mistake: Using shared access keys in connection strings. Why it is wrong: Keys are long-lived secrets with broad rights. Instead: Use managed identity with data roles such as Azure Service Bus Data Sender.

🏛 Senior insight: trade-offs

Most real systems use several of these together: Blob for payloads, Event Grid to react to Azure resource events, Service Bus for the business workflow, Event Hubs for telemetry. The design skill is drawing clear lines so each one does what it is good at, and making every consumer idempotent because none of them is exactly-once.

Cost shapes the choice too. Queue Storage, Service Bus Standard and Event Grid bill per operation, so they are cheap at low volume but grow linearly. Service Bus Premium bills per messaging unit (dedicated capacity, VNet and private endpoints, large messages, predictable latency) and is what regulated production systems usually need. Event Hubs bills per throughput or processing unit, which makes millions of small events cheap where Service Bus would be expensive.

Option When it fits Cost When not to
Queue Storage Simple background jobs, tight budget Very low, per operation Need DLQ, ordering, topics
Service Bus Standard Commands and events at moderate volume Per operation Private endpoints, large messages, strict latency
Service Bus Premium Regulated production messaging Per messaging unit (fixed) Low-volume dev and test
Event Grid Reacting to resource and domain events Per million operations Work that must not be lost without dead-lettering
Event Hubs Telemetry, logs, analytics streams Throughput or processing units Per-message acknowledgement and retries

What I monitor for each

Service Health signals Alert on
Queue Storage Queue length, message age, -poison queue count Oldest message age above SLA
Service Bus Active, dead-lettered and scheduled message counts, server errors, throttled requests DLQ growth, active count trend, throttling
Event Grid Delivery attempts, failed and dead-lettered events, delivery latency Any dead-lettered events, failure rate
Event Hubs Incoming vs outgoing messages, consumer lag per partition, throttled requests Lag above N minutes, throttling
All End-to-end latency from distributed traces in Application Insights, cost per million messages in Cost Management SLO breaches, cost anomalies

🔗 Follow-ups the interviewer may ask

  1. When: Candidate compares Service Bus with Event Hubs Why: Checks they can extend the comparison to RabbitMQ, Kafka and SQS
    How to answer

    Service Bus, RabbitMQ and SQS are queue brokers: a message is delivered, settled and gone. Kafka is a partitioned, retained log: messages stay for the retention period and each consumer group tracks an offset, so you can replay.

    • Ordering: Service Bus sessions, SQS FIFO message groups, Kafka per partition; RabbitMQ only per queue with a single consumer.
    • Guarantees: all are at-least-once in practice, so consumers deduplicate.
    • Operations: Service Bus and SQS are fully managed; RabbitMQ and self-hosted Kafka need a team (or Confluent Cloud / Event Hubs' Kafka endpoint).

    For a .NET system on Azure doing commands and business events, I default to Service Bus. I pick Kafka when I need high-volume streaming and replay. The trade-off is features and simplicity versus throughput and history.

  2. When: Candidate mentions sessions or partitions for ordering Why: Checks they understand what breaks ordering and how to design around it
    How to answer

    Global ordering means one consumer processing one message at a time, which kills throughput, so real systems guarantee order per key: per order, customer or account.

    • Service Bus: set SessionId; a ServiceBusSessionProcessor locks a session to one receiver and processes it in order, while different sessions run in parallel.
    • Kafka: the message key picks the partition, and order holds within it. Adding partitions remaps keys.
    • SQS FIFO: the MessageGroupId works like a session.

    Order breaks with competing consumers, retries, dead-lettering and rebalances. Better still, design so order doesn't matter: version numbers with "ignore older", events that carry full state, or commutative updates. The trade-off is that per-key order lets one stuck message block every later message for that key.

  3. When: Candidate mentions dead-letter queues Why: Checks they can diagnose and recover from poison messages in production
    How to answer

    First I work out which problem I have:

    • Poison messages: a few messages always fail.
    • A failing dependency: every message fails.
    • Slow consumers: nothing fails, they just can't keep up.

    To tell them apart I use Service Bus metrics (incoming, completed, abandoned, dead-lettered), the DLQ's DeadLetterReason and DeadLetterErrorDescription, DeliveryCount, and traces grouped by exception.

    Poison messages loop when handlers catch and abandon forever, re-publish failures as new messages, or MaxDeliveryCount is huge. The fix: dead-letter permanent failures immediately, fix the handler or data, then resubmit from the DLQ in batches to an idempotent consumer. Scale consumers only up to the downstream's limit. To prevent it: alerts on oldest message age and DLQ count, plus a poison-message test. The trade-off: dead-lettering early keeps the queue flowing, but someone must own the DLQ.

↩ Usually asked after

More in Azure

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me