AZ-305Chapter 74 of 103Objective 4.4

Azure Service Bus Topology Design

This chapter covers Azure Service Bus topology design, a critical topic for the AZ-305 exam. Service Bus is a fully managed enterprise message broker that enables reliable asynchronous communication between applications. Understanding how to design queues, topics, subscriptions, and filters is essential for building scalable, decoupled architectures. Approximately 5-10% of AZ-305 exam questions touch on messaging and eventing, with Service Bus being a key component. This chapter will equip you with the knowledge to design optimal Service Bus topologies for various integration scenarios.

25 min read
Intermediate
Updated May 31, 2026

Service Bus as a Post Office with Queues and Topics

Think of Azure Service Bus as a sophisticated post office. In this analogy, messages are letters, and applications are senders and receivers. The post office has two main services: queues and topics. A queue is like a private mailbox: when a sender drops a letter into a queue, it stays there until a single recipient picks it up. Every letter is delivered exactly once to one consumer. This is perfect for point-to-point communication, like a work order system where one department processes each order. A topic, on the other hand, is like a bulletin board with multiple subscription boxes. When a sender posts a message to the topic, the post office makes copies of that message and places one into each subscription box that matches the message's labels (filters). Each subscription can have its own filter rules, so different subscribers see different subsets of messages. This enables publish/subscribe patterns, like a news alert system where some subscribers get all alerts and others get only weather alerts. The post office also guarantees delivery: if a recipient is temporarily unavailable, the message stays in the queue or subscription until it is successfully processed. It supports scheduled delivery, message deferral, and dead-lettering for poison messages. Just as a real post office uses sorting rules and delivery guarantees, Service Bus uses queues, topics, subscriptions, filters, and actions to reliably route messages between distributed applications.

How It Actually Works

What is Azure Service Bus and Why Does It Exist?

Azure Service Bus is a fully managed enterprise message broker that provides reliable asynchronous messaging between applications. It exists to decouple applications, enabling them to communicate without being directly connected or available at the same time. This improves scalability, resilience, and maintainability. Service Bus supports two primary messaging patterns: queues (point-to-point) and topics (publish/subscribe). It also provides features like message sessions, scheduled delivery, duplicate detection, dead-lettering, and transaction support.

How Service Bus Works Internally

Service Bus operates as a middleware layer. When a sender sends a message, it is stored in a queue or topic until a receiver retrieves it. For queues, each message is delivered to a single consumer (competing consumers pattern). For topics, each subscription receives a copy of the message, and filters can control which messages are delivered to which subscription. Messages are delivered in FIFO order by default, but sessions can enforce strict ordering and grouping.

Key Components

Namespace: A container for all messaging components. It provides a unique FQDN (e.g., mynamespace.servicebus.windows.net). Namespaces are scoped to a region and can contain multiple queues and topics.

Queue: A FIFO message buffer. Messages are stored until consumed. Supports at-least-once delivery (default) and at-most-once via duplicate detection.

Topic: A message channel that supports multiple subscriptions. Each subscription acts like a queue that receives a copy of messages matching its filter.

Subscription: A named entity within a topic that receives messages. Each subscription has a filter and optional action.

Filter: A SQL-like expression that selects which messages go to a subscription. Types: Boolean filters (true/false), SQL filters (e.g., sys.Label='urgent'), and correlation filters (match properties).

Action: A SQL-like expression that modifies message properties when a filter matches.

Dead-Letter Queue (DLQ): A sub-queue for messages that cannot be processed. Messages move here after exceeding max delivery count or due to errors.

Defaults and Timers

Default Time-to-Live (TTL): 14 days for messages. Configurable per queue/topic.

Lock Duration: 30 seconds for peek-lock mode. Messages are locked to prevent other consumers from processing them. If the lock expires, the message becomes available again.

Max Delivery Count: Default 10. After this, message is moved to DLQ.

Duplicate Detection Window: Default 30 seconds. Messages with the same MessageId within this window are deduplicated.

Scheduled Delivery: Messages can be scheduled with ScheduledEnqueueTimeUtc (up to 10 days in the future).

Session Idle Timeout: Default 60 seconds for sessions.

Configuration and Verification Commands

Using Azure CLI:

# Create a namespace
az servicebus namespace create --name mynamespace --resource-group myrg --location eastus

# Create a queue
az servicebus queue create --namespace-name mynamespace --resource-group myrg --name myqueue --max-delivery-count 5 --default-message-time-to-live P14D

# Create a topic
az servicebus topic create --namespace-name mynamespace --resource-group myrg --name mytopic

# Create a subscription with a SQL filter
az servicebus topic subscription create --namespace-name mynamespace --resource-group myrg --topic-name mytopic --name mysub
az servicebus topic subscription rule create --namespace-name mynamespace --resource-group myrg --topic-name mytopic --subscription-name mysub --name myfilter --filter-sql-expression "sys.Label='urgent'"

# Send a message (using .NET SDK)
// var sender = client.CreateSender("myqueue");
// await sender.SendMessageAsync(new ServiceBusMessage("Hello"));

# Receive a message (using .NET SDK)
// var receiver = client.CreateReceiver("myqueue");
// var message = await receiver.ReceiveMessageAsync();
// await receiver.CompleteMessageAsync(message);

Interaction with Related Technologies

Azure Functions: Can be triggered by Service Bus queues/topics. Functions can process messages in batches.

Logic Apps: Connectors for Service Bus allow workflow integration.

Event Grid: For event-driven scenarios, Event Grid is lighter weight. Service Bus is for high-value, reliable messaging.

Azure Relay: For hybrid connections, not messaging.

Event Hubs: For telemetry ingestion at scale, not for enterprise messaging with features like sessions and transactions.

Scaling and Performance

Throughput Units (TUs): For premium tier, messaging units (MUs) determine throughput. Standard tier uses shared capacity.

Partitioning: In standard tier, queues/topics can be partitioned (16 partitions) for higher throughput. Premium tier is always partitioned.

Max Message Size: 256 KB for standard, 1 MB for premium (configurable up to 1 MB).

Max Queue/Topic Size: 1-80 GB for standard, 1-80 GB for premium (configurable).

Topology Design Considerations

When to use queues vs topics: Use queues for point-to-point communication (e.g., order processing). Use topics for broadcast or fan-out (e.g., event notifications).

Filter design: Use SQL filters for complex logic (e.g., user.region='EU'). Use correlation filters for simple matching (e.g., label='urgent').

Session usage: Use sessions when you need message ordering and grouping by session ID (e.g., all messages for a chat room).

Duplicate detection: Enable when idempotent processing is not guaranteed. Set DuplicateDetectionHistoryTimeWindow appropriately.

Dead-lettering: Configure maxDeliveryCount and handle DLQ messages separately.

Cross-region replication: Use Geo-Disaster Recovery (paired regions) for high availability. For active-active, use multiple namespaces with client-side routing.

Advanced Features

Transactions: Group operations (send, receive, complete) in a transaction for atomicity.

Auto-forwarding: Chain queues/topics so messages are automatically forwarded.

Scheduled messages: Use for delayed processing.

Message deferral: Defer a message to process later, using sequence number.

Batching: Send/receive multiple messages in one operation for efficiency.

Security

Shared Access Signatures (SAS): Token-based authentication for namespaces, queues, topics.

Azure Active Directory (AAD): Role-based access control (RBAC) for managed identities.

Firewall and VNet Service Endpoints: Restrict access to specific networks.

Private Endpoints: Use for private connectivity from VNets.

This deep understanding of Service Bus internals and configuration will help you design robust messaging topologies and answer exam questions accurately.

Walk-Through

1

Define messaging requirements

Start by identifying the communication pattern needed. Ask: Is this point-to-point or publish/subscribe? What are the reliability requirements (at-least-once vs at-most-once)? Do you need ordering or grouping? What is the expected message volume and size? For example, an order processing system typically uses a queue because each order is processed by one service. A notification system uses a topic because multiple subscribers (email, SMS, push) need copies. Document the message schema, expected throughput, and latency requirements. This step determines whether you use a queue, topic, or a combination.

2

Design namespace and entity hierarchy

Choose a naming convention for namespaces and entities. Namespaces should be unique globally and reflect the application domain, e.g., `orders-ns.servicebus.windows.net`. Within a namespace, create queues or topics with descriptive names like `orders-queue` or `notifications-topic`. Consider using separate namespaces for different environments (dev, test, prod) or for security isolation. For large deployments, you may have multiple namespaces per region. Ensure the namespace tier (Standard or Premium) matches throughput and feature requirements. Premium offers dedicated resources and larger message sizes.

3

Configure queues with appropriate settings

For each queue, set the following: `maxDeliveryCount` (default 10) to control dead-lettering; `defaultMessageTimeToLive` (default 14 days) to expire old messages; `lockDuration` (default 30 seconds) for peek-lock mode; `duplicateDetectionHistoryTimeWindow` (default 30 seconds) if needed; `enablePartitioning` (Standard only) for higher throughput; `enableBatchedOperations` for batching. Also set `requiresSession` if you need message grouping. For example, a queue for critical orders might have `maxDeliveryCount` = 5 and TTL = 7 days. Use `autoDeleteOnIdle` to clean up unused queues.

4

Design topics with subscriptions and filters

For each topic, define subscriptions based on subscriber groups. Each subscription can have a filter: SQL filter (e.g., `sys.Label='urgent'`) or correlation filter (match properties like `label='urgent'`). Use actions to modify message properties (e.g., add a timestamp). For example, a `news-topic` might have subscriptions: `sports-sub` with filter `category='sports'`, `weather-sub` with filter `category='weather'`. Create a default subscription with no filter for all messages. Set `maxDeliveryCount` and TTL per subscription. Use `forwardTo` to chain subscriptions to other queues/topics.

5

Implement security and access control

Secure the namespace using either SAS keys or Azure AD RBAC. For SAS, generate keys with appropriate permissions (Send, Listen, Manage) and distribute only to authorized applications. For AAD, assign roles like `Azure Service Bus Data Sender` or `Azure Service Bus Data Receiver` to managed identities or service principals. Use firewalls and service endpoints to restrict network access. For sensitive data, enable encryption at rest (default) and in transit (HTTPS). Consider private endpoints for VNet integration. Regularly rotate keys and use managed identities where possible.

6

Test and monitor the topology

After deployment, test message flow using SDKs or tools like Service Bus Explorer. Verify that messages are sent and received correctly, filters work as expected, and dead-lettering occurs when appropriate. Monitor key metrics in Azure Monitor: incoming/outgoing messages, active messages, dead-lettered messages, server errors, and throttled requests. Set up alerts for high dead-letter counts or queue depth. Use diagnostic logs to capture send/receive operations for troubleshooting. Performance test with expected load to ensure throughput meets requirements.

What This Looks Like on the Job

Enterprise Scenario 1: Order Processing System

A large e-commerce company uses Service Bus to decouple their web frontend from the order fulfillment backend. When a customer places an order, the frontend sends a message to an orders-queue. The fulfillment service listens on that queue and processes orders. The queue is configured with maxDeliveryCount = 3 and TTL = 7 days. Duplicate detection is enabled with a 5-minute window to prevent duplicate orders due to retries. Sessions are not needed because ordering is independent. The system handles 10,000 orders per minute. They use a Premium namespace with 4 messaging units to meet throughput. A dead-letter queue captures failed orders for manual review. Misconfiguration: If maxDeliveryCount is too high (e.g., 100), poison messages will retry many times, wasting resources. If TTL is too short, legitimate orders may expire before processing during peak times.

Enterprise Scenario 2: Real-Time Notification System

A financial services company sends notifications to traders via email, SMS, and mobile push. They use a notifications-topic with three subscriptions: email-sub, sms-sub, and push-sub. Each subscription has a SQL filter based on user preferences stored in message properties (e.g., user.email='true'). The topic is configured with duplicate detection to avoid sending duplicate notifications. Scheduled messages are used for delayed alerts (e.g., market open reminders). They use correlation filters for high-priority alerts to bypass SQL evaluation. The system sends 1 million messages per day. Misconfiguration: If filters are too complex (e.g., multiple joins), they can slow down message delivery. They learned to use correlation filters for simple matching and SQL filters only when necessary.

Enterprise Scenario 3: Cross-Region Disaster Recovery

A global logistics company needs high availability across regions. They deploy two Service Bus namespaces in paired regions (e.g., West US and East US). They use Geo-Disaster Recovery to automatically failover if the primary region goes down. The secondary namespace is passive until failover. They also implement client-side logic to send messages to both namespaces for active-active scenarios, using duplicate detection to handle duplicates. They monitor queue depth and dead-letter counts across both regions. Misconfiguration: Forgetting to configure the failover alias and test it regularly leads to prolonged downtime. They now conduct quarterly DR drills.

How AZ-305 Actually Tests This

Exactly What AZ-305 Tests on Service Bus Topology

The AZ-305 exam (Designing Microsoft Azure Infrastructure Solutions) focuses on designing messaging solutions that meet business requirements. Objective 4.4: Design a messaging solution. You must be able to choose between queues and topics based on requirements. The exam tests your understanding of:

When to use queues vs topics (point-to-point vs publish/subscribe)

Filter types (SQL, correlation, boolean) and their use cases

Session-based messaging for ordering and grouping

Duplicate detection and its time window (default 30 seconds)

Dead-lettering and max delivery count (default 10)

Scaling: Standard vs Premium tier differences (message size, throughput units)

Geo-Disaster Recovery and Geo-Replication

Security: SAS vs AAD, firewalls, private endpoints

Common Wrong Answers and Why Candidates Choose Them

1.

Choosing Event Grid instead of Service Bus for reliable messaging: Candidates see "event" and think Event Grid, but Event Grid is for event-driven reactions (webhooks) not for reliable message queuing with features like sessions, transactions, and dead-lettering. Service Bus is for high-value, reliable messaging.

2.

Using topics when queues are appropriate: Candidates think topics are always better because they are more flexible. But for point-to-point, a queue is simpler and has lower latency. Topics add overhead of subscriptions and filters.

3.

Enabling partitioning for all queues in Premium tier: Partitioning is automatically enabled in Premium and cannot be disabled. In Standard, it's optional. Candidates may incorrectly think they need to enable it manually.

4.

Setting duplicate detection window too large: Default is 30 seconds. Setting it to hours can cause high memory usage and message rejection. Candidates may set it to 24 hours unnecessarily.

Specific Numbers and Terms That Appear on the Exam

Default TTL: 14 days

Default lock duration: 30 seconds

Default max delivery count: 10

Duplicate detection window: 30 seconds

Max message size: 256 KB (Standard), 1 MB (Premium)

Standard tier: shared throughput, up to 80 GB per queue/topic

Premium tier: dedicated resources, message units (1, 2, 4, 8, 16)

Partitioning: 16 partitions in Standard (if enabled)

Edge Cases and Exceptions

Session-based queues: If requiresSession is true, you must set the session ID on each message. The exam may test that sessions enforce FIFO per session ID, not globally.

Auto-forwarding: Messages can be forwarded from one queue to another, but the destination must exist. The exam may test that auto-forwarding is a one-way chain.

Scheduled messages: Messages can be scheduled up to 10 days in advance. The exam may ask how to delay processing.

Deferral: Messages can be deferred and retrieved later by sequence number. This is different from scheduling.

How to Eliminate Wrong Answers

Read the requirement: If it says "each message must be processed by exactly one consumer" → queue. If "multiple consumers need copies" → topic.

If ordering and grouping are needed → sessions.

If idempotent processing is not guaranteed → duplicate detection.

If you need to handle poison messages → dead-letter queue.

If throughput is high and dedicated resources needed → Premium tier.

Understand the difference between Event Grid (event-driven, no queuing) and Service Bus (message queuing).

Key Takeaways

Use queues for point-to-point messaging (each message processed once) and topics for publish/subscribe (multiple consumers).

Default message TTL is 14 days; lock duration is 30 seconds; max delivery count is 10.

Duplicate detection window is 30 seconds; set MessageId for deduplication.

Standard tier: 256 KB max message size; Premium: 1 MB with dedicated resources.

Sessions enforce strict FIFO ordering per session ID; set requiresSession on queue/topic.

Dead-letter queue captures messages after max delivery count exceeded or due to errors.

Geo-Disaster Recovery provides automatic failover to paired region; test regularly.

Secure with SAS keys or Azure AD RBAC; use firewalls and private endpoints for network security.

Use SQL filters for complex filtering, correlation filters for simple property matching.

Premium tier supports larger messages, dedicated throughput, and partitioning always enabled.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Queue

Point-to-point communication: each message consumed by one receiver

Simpler design: no subscriptions or filters needed

Lower latency and overhead compared to topics

Supports competing consumers pattern for load balancing

Best for command-style messages (e.g., process order)

Topic

Publish/subscribe: multiple subscribers can receive copies

Requires subscriptions with optional filters for selective delivery

Higher overhead due to message copying to each subscription

Supports fan-out pattern for broadcasting events

Best for event-style notifications (e.g., order placed)

Watch Out for These

Mistake

Service Bus queues guarantee FIFO order for all messages.

Correct

By default, queues provide best-effort FIFO but not strict ordering. For strict FIFO ordering, you must use sessions. Without sessions, messages can be reordered due to parallel processing or retries.

Mistake

You can send messages larger than 256 KB in Standard tier.

Correct

The maximum message size in Standard tier is 256 KB. For larger messages (up to 1 MB), you must use Premium tier. Messages exceeding the limit are rejected.

Mistake

Topic subscriptions automatically receive all messages.

Correct

By default, a subscription receives all messages. However, you can add filters (SQL, correlation, boolean) to selectively receive messages. Without filters, all messages are delivered.

Mistake

Duplicate detection prevents all duplicate messages.

Correct

Duplicate detection only works within the configured time window (default 30 seconds). Messages with the same `MessageId` sent outside this window are not deduplicated. It does not prevent duplicates from different senders with different IDs.

Mistake

Service Bus can be used for real-time event streaming like Event Hubs.

Correct

Service Bus is for enterprise messaging with features like transactions and sessions. It is not designed for high-throughput event streaming. Event Hubs is better for telemetry ingestion at scale (millions of events per second).

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between a queue and a topic in Azure Service Bus?

A queue is a point-to-point messaging channel where each message is consumed by a single receiver. A topic is a publish/subscribe channel where each subscription receives a copy of the message. Use queues for command-style processing (e.g., order processing) and topics for event broadcasting (e.g., notifications).

How do I ensure messages are processed in order?

Enable sessions on the queue or topic by setting `requiresSession` to true. Then, set the `SessionId` property on each message. Messages with the same session ID are delivered in FIFO order and processed sequentially by a single consumer. Without sessions, order is not guaranteed.

What is the maximum message size in Service Bus?

In Standard tier, the maximum message size is 256 KB. In Premium tier, it is 1 MB. Messages larger than the limit are rejected. You can increase the size in Premium by setting the `maxMessageSizeInKilobytes` property (up to 1024 KB).

How does duplicate detection work?

Duplicate detection uses the `MessageId` property. When enabled, Service Bus stores message IDs for a configurable time window (default 30 seconds). If a message with the same ID arrives within that window, it is discarded. This prevents duplicate processing due to sender retries.

What happens when a message reaches max delivery count?

The message is moved to the dead-letter queue (DLQ) associated with the queue or subscription. The DLQ stores messages that could not be processed. You can inspect and manually handle them. The default max delivery count is 10.

Can I use Service Bus for real-time event streaming?

Service Bus is not optimized for high-throughput event streaming. For that, use Azure Event Hubs which can ingest millions of events per second. Service Bus is for enterprise messaging with features like sessions, transactions, and dead-lettering.

How do I secure Service Bus?

Use Shared Access Signatures (SAS) for token-based authentication or Azure Active Directory (AAD) for role-based access. Restrict network access with firewalls and service endpoints, or use private endpoints for VNet integration. Enable encryption in transit (HTTPS) and at rest (default).

Terms Worth Knowing

Ready to put this to the test?

You've just covered Azure Service Bus Topology Design — now see how well it sticks with free AZ-305 practice questions. Full explanations included, no account needed.

Done with this chapter?