Hello John Wong Yek Hon,
Welcome to Microsoft Q&A and Thank you for reaching out.
You’re right to think carefully about this migration, especially with the goal of minimizing downtime while tightening security using a private endpoint. However, there is an important routing behavior in Azure IoT Hub to be aware of.
Key clarification on IoT Hub routing behavior
Azure IoT Hub does not deduplicate messages across routing rules. Each routing rule is evaluated independently. If multiple routing rules match the same D2C message, IoT Hub will attempt to deliver that message once per matching rule.
This means:
- If two routing rules are active at the same time
Both match the same set of D2C messages
Both route to the same Service Bus queue
The Service Bus queue will receive duplicate messages (one copy per rule). There is no “only one rule wins” or competition logic, and messages will not be merged or dropped automatically.
So while messages will not be lost, duplication is expected and by design if routes overlap.
Why this happens
IoT Hub routing is intentionally fan-out based, allowing the same message to be sent to multiple endpoints. IoT Hub does not have awareness that two routes point to the same physical destination.
Impact on your migration plan
Running the old (key-based) route and the new (managed identity / trusted Microsoft services) route in parallel to the same queue is technically supported, but it will result in duplicate messages during the overlap period.
Recommended approaches to minimize downtime without duplicates
1: Controlled cutover
Create the new Service Bus endpoint with private endpoint and managed identity.
Create the new IoT Hub route, but with a query that does not match live traffic yet.
Validate permissions and connectivity.
Disable the old routing rule.
Update the new routing rule query to match production messages.
Disable public access on the Service Bus.
This avoids any overlap and prevents duplication.
2: Temporary validation destination
- Route the new rule to a temporary Service Bus queue for testing.
- Once validated, switch it to the production queue and disable the old rule.
3: Downstream deduplication
If a short overlap window is acceptable:
Enable Service Bus duplicate detection
Ensure devices set a deterministic messageId
This mitigates duplicates at the Service Bus level, but does not change IoT Hub routing behavior.
Best practices
- Use IoT Hub route test functionality to validate routing queries before enabling them.
- Monitor Routing Deliveries and Routing Latency metrics during the transition.
- Keep the fallback route enabled to avoid accidental message drops due to misconfigured queries.
Please refer this
I Hope this helps. Do let me know if you have any further queries.
Thank you!