Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Azure Service Bus

Azure Service Bus is Microsoft's enterprise message broker, providing reliable message delivery with advanced features like sessions, transactions, dead-lettering, and scheduled delivery. It serves as the backbone for many enterprise integration patterns on Azure. When pg_tide publishes to Service Bus, your outbox messages are delivered to queues or topics where Azure Functions, Logic Apps, or custom applications can process them with enterprise-grade reliability.

When to Use This Sink

Choose Azure Service Bus when your infrastructure runs on Azure, when you need enterprise messaging features (sessions for ordered processing, transactions, scheduled messages), or when you are integrating with Azure-native services like Azure Functions and Logic Apps. Service Bus is particularly strong for ordered message processing and complex routing scenarios within Azure.

Configuration

SELECT tide.relay_set_outbox(
    'events-to-servicebus',
    'events',
    'servicebus-relay',
    '{
        "sink_type": "servicebus",
        "connection_string": "${env:SERVICEBUS_CONNECTION_STRING}",
        "queue_or_topic": "outbox-events",
        "session_id": "{stream_table}",
        "batch_size": 50
    }'::jsonb
);

Configuration Reference

ParameterTypeDefaultDescription
sink_typestringMust be "servicebus"
connection_stringstringService Bus connection string with send permissions
queue_or_topicstringTarget queue or topic name
session_idstringnullSession ID template for session-enabled entities
batch_sizeint50Messages per batch send
content_typestring"application/json"Message content type
propertiesobjectnullCustom application properties

Delivery Guarantees

Service Bus provides at-least-once delivery with server-side duplicate detection available. When sending to session-enabled queues/topics, messages within the same session are delivered in FIFO order. The relay commits offsets only after Service Bus acknowledges receipt.

Troubleshooting

  • "Unauthorized access" — Verify connection string has Send permission on the entity
  • "Entity not found" — Queue/topic does not exist; create it in the Azure portal
  • "Session ID required" — The target entity requires sessions; set session_id

Further Reading