Azure Service Bus icon

Azure Service Bus

Send and receive messages from Azure Service Bus

Actions3

Overview

This node enables interaction with Azure Service Bus queues, specifically supporting sending and receiving messages. For the Receive Messages operation on a queue, it allows retrieving messages from an Azure Service Bus queue using either the official Azure SDK or the HTTP REST API protocol (though receiving is only supported via the SDK). It supports advanced features such as session-aware message receiving, including accepting specific sessions or the next available session, managing session state, and controlling message receive modes.

Common scenarios where this node is beneficial include:

  • Processing messages asynchronously from a queue in workflows.
  • Handling session-enabled queues to maintain ordered processing of related messages.
  • Integrating Azure Service Bus messaging into automation pipelines for event-driven architectures.

Practical example:

  • A workflow that polls an Azure Service Bus queue for new orders, processes each order message, and updates session state to track progress.

Properties

Name Meaning
Protocol Protocol to use for Azure Service Bus connection. Options: "Azure SDK (Recommended)" or "HTTP REST API" (firewall-friendly). Receiving messages is only supported with the SDK.
Queue Name The name of the Azure Service Bus queue to receive messages from.
Session Mode How to handle sessions when receiving messages (only for SDK protocol):
- No Sessions: Standard queue without session support.
- Specific Session: Receive messages from a specified session ID.
- Next Available Session: Accept the next available session.
Session ID (Required if Session Mode is "Specific") The specific session ID to receive messages from.
Session Timeout (seconds) Maximum time to wait when accepting a session (for "Specific" or "Next Available" session modes).
Manage Session State Whether to retrieve and update the session state after receiving messages (only for session modes other than "No Sessions").
New Session State JSON object string to set as the new session state after processing (leave empty to not update).
Max Message Count Maximum number of messages to receive in one execution.
Max Wait Time (seconds) Maximum time to wait for messages before returning.
Receive Mode Mode of receiving messages:
- Peek Lock: Messages are locked and must be explicitly completed or abandoned.
- Receive and Delete: Messages are automatically deleted upon receipt.

Output

The node outputs an array of items, each representing a received message with the following JSON structure:

{
  "messageId": "string",
  "body": "any",                      // Parsed message body; JSON parsed if possible, otherwise raw string
  "contentType": "string",
  "enqueuedTimeUtc": "string",       // Timestamp when message was enqueued
  "applicationProperties": {         // Custom properties attached to the message
    "key": "value"
  },
  "deliveryCount": number,
  "sequenceNumber": "string",
  "sessionId": "string | null",
  "sessionInfo": {                   // Present if session mode is used
    "sessionId": "string",
    "sessionState": any,             // Current session state (if managed)
    "isSessionMessage": true
  }
}

If the receive mode is "Peek Lock," messages are explicitly completed after processing to remove them from the queue.

The node does not output binary data for this operation.

Dependencies

  • Requires an Azure Service Bus connection string credential configured in n8n.
  • Uses the official @azure/service-bus SDK for the recommended protocol.
  • Optionally supports HTTP REST API protocol but receiving messages is only supported via the SDK.
  • If using the SDK with WebSocket transport, requires the ws package (automatically handled).
  • Node expects network access to Azure Service Bus endpoints.

Troubleshooting

  • Missing or invalid connection string: The node throws an error if the connection string is missing or contains placeholder blank values. Ensure the connection string is correctly entered in credentials.
  • Protocol mismatch: Receiving messages is only supported with the Azure SDK protocol. Selecting HTTP REST API for receiving will cause an error.
  • Session acceptance failures: Errors can occur if the specified session ID does not exist or no sessions are available when using session modes. Check session IDs and queue configuration.
  • JSON parsing errors: Message bodies that look like JSON but are malformed will remain as strings; this is normal behavior.
  • WebSocket transport fallback: If WebSocket transport is unavailable, the node falls back to default transport with a warning.
  • Message Body empty on send: When sending messages (not part of this operation), an empty message body causes an error.

Links and References

Discussion