az servicebus queue show --namespace-name <namespace> --resource-group <resource-group> --name <queue> --query "{requiresDuplicateDetection:requiresDuplicateDetection,duplicateDetectionHistoryTimeWindow:duplicateDetectionHistoryTimeWindow,status:status}" --output jsonService Bus duplicate detection
Service Bus duplicate detection lets a queue or topic remember application-supplied MessageId values for a configured window. If the same MessageId is sent again within that window, the send succeeds but the duplicate message is dropped, reducing uncertainty after retries or network failures.
Source: Microsoft Learn - Duplicate detection in Azure Service Bus Reviewed 2026-05-24
- Exam trap
- Generating a new GUID for every retry and expecting the broker to recognize duplicates that no longer share a MessageId.
- Production check
- Show the entity and confirm duplicate detection is enabled before relying on retry-safe sending behavior.
Article details and learning context
- Aliases
- Service Bus duplicate detection window, requiresDuplicateDetection, duplicateDetectionHistoryTimeWindow, MessageId deduplication
- Difficulty
- intermediate
- CLI mappings
- 4
- Last verified
- 2026-05-24
- Review level
- template-specs-five-use-cases
- Article depth
- template-specs-five-use-cases-three-case-studies
Understand the concept
In plain English
Service Bus duplicate detection protects a queue or topic from accepting the same logical message more than once during a configured time window. The sender supplies a stable MessageId, usually tied to a business operation such as an order, payment, or notification. If the client retries after a timeout and sends the same MessageId again, Service Bus accepts the send request but discards the duplicate copy. This does not replace idempotent processing, but it lowers duplicate work caused by uncertain sends.
Why it matters
Duplicate detection matters because distributed systems often cannot tell whether a send succeeded. A client might send a message, lose the acknowledgment, restart, and send the same business command again. Without duplicate detection, downstream systems may ship two packages, send two emails, or post two accounting updates. With stable MessageId values, Service Bus can discard repeat sends inside the window while the client safely retries. The feature is not magic exactly-once processing across the entire workflow; consumers must still be idempotent. It is a broker-side guardrail that reduces duplicate pressure at the moment messages enter the system under pressure today.
Technical context
In Azure architecture, duplicate detection is configured on a Service Bus queue or topic, not on the whole namespace. It is supported in Standard and Premium tiers and must be enabled when the entity is created, although the detection window can be adjusted afterward when the feature exists. The broker records MessageId values for the configured history window, which defaults to ten minutes and can be set from twenty seconds to seven days. Partitioning and sessions affect uniqueness through partition key behavior, so design carefully.
Exam context
What to know
operator-ready Azure glossary term with practical use cases, CLI context, and structured case studies
Compare with
Where it is used
Where you see it
- In queue or topic properties, requiresDuplicateDetection and duplicateDetectionHistoryTimeWindow show whether the entity remembers MessageId values and for how long during retry readiness reviews before launch.
- In deployment templates, duplicate detection appears as an entity creation setting, making it a design-time decision rather than a casual runtime toggle for operators and architects.
- In application logs, retry attempts with the same MessageId may report successful sends even though the broker drops duplicate copies inside the window after reconnects.
Common situations
- Let producers retry after network timeouts without creating duplicate order, payment, or fulfillment commands.
- Protect scheduled and immediate notification sends from creating two messages with the same business intent.
- Use deterministic MessageId values during migration from synchronous APIs to Service Bus commands.
- Limit duplicate load on workers during client restart storms or unreliable branch-network connectivity.
- Standardize queue and topic creation templates so duplicate-sensitive workflows never omit the setting accidentally.
Illustrative Azure scenarios
These examples show how the concept can affect design and operations. They are illustrative scenarios, not customer claims.
Scenario 01 Payment orchestration service controls retry duplicates Scenario, objectives, solution, measured impact, and takeaway.
A payment orchestration startup used Service Bus queues to submit settlement commands to several processors. Network timeouts caused senders to retry, and occasional duplicate commands reached reconciliation workers.
- Allow safe producer retries after uncertain send acknowledgments.
- Prevent duplicate settlement commands from entering the queue.
- Keep the detection window short enough for high throughput.
- Make MessageId construction auditable by transaction type.
Architects created a replacement settlement queue with Service Bus duplicate detection enabled and a 30-minute history window matching the longest producer retry policy. Producers generated MessageId from settlement batch ID, processor code, and operation type, so retries reused the same identifier. Consumers remained idempotent and checked settlement state before posting downstream. CLI deployment output proved requiresDuplicateDetection and the history window in staging and production. Application logs recorded MessageId values without exposing card data, and dashboards tracked send retries, accepted sends, and downstream duplicate exceptions.
- Duplicate settlement commands fell from 430 per week to fewer than 12 investigated exceptions.
- Producer retry success improved without adding reconciliation worker throttles.
- Throughput stayed within target after the window was reduced from a tested 2 hours to 30 minutes.
- Auditors could trace every MessageId pattern to a documented business operation.
Duplicate detection works best when MessageId values are deterministic business identifiers and the window matches actual retry behavior.
Scenario 02 Agriculture telemetry handles intermittent satellite links Scenario, objectives, solution, measured impact, and takeaway.
An agricultural equipment provider collected tractor telemetry through rural gateways with intermittent satellite connections. Gateways resent buffered maintenance alerts after reconnecting, creating duplicate work orders for dealers.
- Suppress duplicate maintenance alerts caused by gateway reconnects.
- Keep valid repeated alerts for different fault types.
- Avoid a detection window that slowed peak harvest telemetry.
- Preserve dealer trust in work-order queues.
The IoT integration team created a Service Bus topic with duplicate detection enabled and a 2-hour window that covered typical satellite retry bursts. Gateway software set MessageId to equipment serial number plus fault code plus first-detected timestamp. Topic subscriptions routed alerts to dealer systems, analytics, and warranty review. The team tested scheduled and immediate resend scenarios to confirm duplicate behavior. CLI checks were added to deployment pipelines so any replacement topic had requiresDuplicateDetection enabled. Consumers still performed idempotency checks using work-order state because duplicate detection only protected the broker ingress window.
- Duplicate dealer work orders dropped by 91 percent during the first harvest season.
- Telemetry throughput stayed within SLA after the window was tuned from 24 hours to 2 hours.
- Dealer support calls about repeated alerts fell from 76 per month to 9.
- Pipeline checks caught one staging topic that had been created without duplicate detection.
For unreliable networks, Service Bus duplicate detection reduces retry noise when device software can send the same business MessageId after reconnecting.
Scenario 03 Legal document platform prevents duplicate signing reminders Scenario, objectives, solution, measured impact, and takeaway.
A legal document platform scheduled signing-reminder messages through Service Bus. A scheduler restart sometimes sent immediate and scheduled reminders for the same envelope, frustrating clients and signers.
- Prevent duplicate reminder messages for the same document envelope.
- Handle both scheduled and nonscheduled sends consistently.
- Keep reminders flowing during scheduler restarts.
- Reduce support tickets about repeated signer notifications.
Engineers created a reminder topic with duplicate detection enabled and set the history window to cover the maximum scheduler replay interval. MessageId used envelope ID, signer role, and reminder sequence number. The scheduler reused that identifier whether the send was immediate or scheduled, which let the broker drop duplicates inside the window. CLI validation confirmed the topic setting after each infrastructure deployment. Consumers also checked notification history before emailing signers, because duplicates could still originate from channels outside the topic. Monitoring compared scheduler restarts with duplicate-related support tickets.
- Repeated reminder emails fell by 88 percent in the first month.
- Scheduler restarts no longer caused spikes in duplicate Service Bus messages.
- Support tickets about duplicate signing reminders dropped from 140 to 22 per month.
- Infrastructure reviews found the duplicate-detection setting consistently present across regions.
Duplicate detection is a strong guardrail for scheduled messaging when the sender can reuse the same MessageId for every retry path.
Azure CLI
I use Azure CLI for duplicate-detection work because the most important settings are entity-level and easy to miss during a portal review. CLI lets me show whether a queue or topic has duplicate detection enabled, inspect the history window, confirm tier and partitioning, and compare those values across environments. After ten years of Azure messaging incidents, I also check whether developers are relying on a feature that was never enabled at creation. CLI output gives clean evidence for architecture reviews and migration plans, especially when creating a replacement entity is required to change immutable duplicate-detection capability before production promotion or migration.
Useful for
- Show a queue or topic to confirm duplicate detection is enabled before approving retry-heavy producers.
- Inspect the duplicate-detection history window and compare it with the application's maximum retry duration.
- Create new queues or topics with duplicate detection enabled when an existing entity cannot be changed.
- Export entity settings across environments to find drift in requiresDuplicateDetection or history-window values.
- Review partitioning, session, and batching-related settings before testing duplicate behavior at scale.
Before you run a command
- Confirm tenant, subscription, resource group, namespace, entity type, tier, and whether you are inspecting the active production queue or topic.
- Understand that enabling duplicate detection is a creation-time decision; changing an existing entity may require replacement and migration.
- Check producer behavior because the broker only helps when clients reuse the same application-defined MessageId on retries.
- Review partitioning, sessions, batching, scheduled messages, destructive migration risk, and output format before updating templates or creating replacements.
What the output tells you
- Queue and topic show output confirms whether duplicate detection is required and how long MessageId values are retained.
- SKU and tier details show whether the namespace supports duplicate detection for the intended entity.
- Partitioning and session settings reveal whether uniqueness behavior needs extra testing beyond simple MessageId comparisons.
- Resource IDs and tags help prove which environment was inspected before a producer retry policy is changed.
Mapped commands
Term-specific Azure CLI operations
directaz servicebus topic show --namespace-name <namespace> --resource-group <resource-group> --name <topic> --query "{requiresDuplicateDetection:requiresDuplicateDetection,duplicateDetectionHistoryTimeWindow:duplicateDetectionHistoryTimeWindow,status:status}" --output jsonaz servicebus queue create --namespace-name <namespace> --resource-group <resource-group> --name <queue> --enable-duplicate-detection true --duplicate-detection-history-time-window <duration>az servicebus topic create --namespace-name <namespace> --resource-group <resource-group> --name <topic> --enable-duplicate-detection true --duplicate-detection-history-time-window <duration>Architecture context
Architecturally, duplicate detection belongs at the ingress point where uncertain sends happen. It works best when the application can reconstruct the same MessageId from business context, such as invoice number plus operation type, rather than generating a new random GUID on every retry. Architects should pick the smallest window that covers realistic retry and failover behavior because longer windows retain more IDs and can reduce throughput. The feature must be decided at entity creation, so Bicep and Terraform modules should make it explicit. If partitioning, batching, scheduled messages, or sessions are involved, test uniqueness rules before claiming the workflow is protected against duplicates.
- Security
- Security impact is indirect, but still important because duplicate detection relies on message metadata chosen by the sending application. It does not encrypt data, authenticate clients, or authorize access. The risk appears when teams put sensitive business details directly into MessageId values or assume duplicate detection protects against malicious replay. Use authentication, authorization rules, managed identity, private endpoints, and encryption controls for security. Keep MessageId values stable and meaningful, but avoid unnecessary personal or secret data. For compliance, document how duplicate suppression is achieved and how discarded duplicate sends are observed through application telemetry, especially in regulated systems and partner workflows.
- Cost
- Cost impact is indirect but practical. Duplicate messages can trigger extra transactions, worker executions, API calls, emails, shipments, support tickets, and compensating actions. Duplicate detection prevents some of that waste at ingress, especially when clients retry after network uncertainty. It also has a cost tradeoff: a longer detection window retains more MessageId records and can reduce throughput, which may require more capacity or Premium messaging units for high-volume systems. The feature is cheapest when designed with short, realistic windows and stable identifiers. It is expensive when discovered too late, because migration to a new entity becomes necessary and audits later.
- Reliability
- Reliability impact is direct because duplicate detection makes retry behavior safer when send outcomes are uncertain. It reduces duplicate work at the broker boundary, but only within the configured time window and only when the same MessageId is reused. The feature must be enabled at entity creation, so discovering it is off during an incident usually means creating a replacement queue or topic and migrating traffic. Reliable designs pair duplicate detection with idempotent consumers, dead-letter handling, retry policies, and clear MessageId construction rules. Long windows may protect slow retries but can affect throughput, so tune the window for real failure scenarios.
- Performance
- Performance impact is direct because Service Bus must compare incoming MessageId values against the retained duplicate-detection history. Longer windows retain more identifiers, which can reduce throughput for high-volume queues or topics. Batching and partitioning require extra care because uniqueness can depend on partition-related properties, and deduplication with batching is not always the best pattern. The performance benefit is fewer duplicate downstream operations, which often matters more than broker overhead. For busy entities, keep the window as small as the retry design allows, monitor incoming requests and latency, and validate behavior under realistic retry storms before peak traffic events and launches.
- Operations
- Operators inspect duplicate detection when reviewing queues, topics, retry incidents, and message-processing anomalies. They confirm requiresDuplicateDetection, duplicateDetectionHistoryTimeWindow, SKU, partitioning, and whether producers actually send stable MessageId values. During incidents, they compare application logs with Service Bus metrics to determine whether duplicate sends were dropped or consumers processed duplicates from another path. Changes are mostly architectural because enabling the feature after creation requires a replacement entity. Runbooks should describe how to create the new entity, forward or drain old traffic, update producers, and validate that duplicate message IDs are being reused correctly. I also verify SDK versions and retry policy documentation.
Common mistakes
- Generating a new GUID for every retry and expecting the broker to recognize duplicates that no longer share a MessageId.
- Assuming duplicate detection can be enabled later on an existing queue or topic without creating a replacement entity.
- Choosing a seven-day window by default and then wondering why high-throughput sends slow down under load.
- Treating duplicate detection as the only safeguard and skipping idempotent consumer logic or reconciliation checks.