Azure Service Bus Queues binding spec

Detailed documentation on the Azure Service Bus Queues binding component

Component format

To setup Azure Service Bus Queues binding create a component of type bindings.azure.servicebusqueues. See this guide on how to create and apply a binding configuration.

Connection String Authentication

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. spec:
  6. type: bindings.azure.servicebusqueues
  7. version: v1
  8. metadata:
  9. - name: connectionString # Required when not using Azure Authentication.
  10. value: "Endpoint=sb://{ServiceBusNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key};EntityPath={ServiceBus}"
  11. - name: queueName
  12. value: queue1
  13. # - name: timeoutInSec # Optional
  14. # value: 60
  15. # - name: handlerTimeoutInSec # Optional
  16. # value: 60
  17. # - name: disableEntityManagement # Optional
  18. # value: "false"
  19. # - name: maxDeliveryCount # Optional
  20. # value: 3
  21. # - name: lockDurationInSec # Optional
  22. # value: 60
  23. # - name: lockRenewalInSec # Optional
  24. # value: 20
  25. # - name: maxActiveMessages # Optional
  26. # value: 10000
  27. # - name: maxConcurrentHandlers # Optional
  28. # value: 10
  29. # - name: defaultMessageTimeToLiveInSec # Optional
  30. # value: 10
  31. # - name: autoDeleteOnIdleInSec # Optional
  32. # value: 3600
  33. # - name: minConnectionRecoveryInSec # Optional
  34. # value: 2
  35. # - name: maxConnectionRecoveryInSec # Optional
  36. # value: 300
  37. # - name: maxRetriableErrorsPerSec # Optional
  38. # value: 10
  39. # - name: publishMaxRetries # Optional
  40. # value: 5
  41. # - name: publishInitialRetryIntervalInMs # Optional
  42. # value: 500

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

Spec metadata fields

FieldRequiredBinding supportDetailsExample
connectionStringYInput/OutputThe Service Bus connection string. Required unless using Azure AD authentication.“Endpoint=sb://**
queueNameYInput/OutputThe Service Bus queue name. Queue names are case-insensitive and will always be forced to lowercase.“queuename”
timeoutInSecNInput/OutputTimeout for all invocations to the Azure Service Bus endpoint, in seconds. Note that this option impacts network calls and it’s unrelated to the TTL applies to messages. Default: 6060
namespaceNameNInput/OutputParameter to set the address of the Service Bus namespace, as a fully-qualified domain name. Required if using Azure AD authentication.“namespace.servicebus.windows.net”
disableEntityManagementNInput/OutputWhen set to true, queues and subscriptions do not get created automatically. Default: “false”“true”, “false”
lockDurationInSecNInput/OutputDefines the length in seconds that a message will be locked for before expiring. Used during subscription creation only. Default set by server.30
autoDeleteOnIdleInSecNInput/OutputTime in seconds to wait before auto deleting idle subscriptions. Used during subscription creation only. Default: 0 (disabled)3600
defaultMessageTimeToLiveInSecNInput/OutputDefault message time to live, in seconds. Used during subscription creation only.10
maxDeliveryCountNInput/OutputDefines the number of attempts the server will make to deliver a message. Used during subscription creation only. Default set by server.10
minConnectionRecoveryInSecNInput/OutputMinimum interval (in seconds) to wait before attempting to reconnect to Azure Service Bus in case of a connection failure. Default: 25
maxConnectionRecoveryInSecNInput/OutputMaximum interval (in seconds) to wait before attempting to reconnect to Azure Service Bus in case of a connection failure. After each attempt, the component waits a random number of seconds, increasing every time, between the minimum and the maximum. Default: 300 (5 minutes)600
maxActiveMessagesNDefines the maximum number of messages to be processing or in the buffer at once. This should be at least as big as the maximum concurrent handlers. Default: 11
handlerTimeoutInSecNInputTimeout for invoking the app’s handler. Default: 0 (no timeout)30
minConnectionRecoveryInSecNInputMinimum interval (in seconds) to wait before attempting to reconnect to Azure Service Bus in case of a connection failure. Default: 25
maxConnectionRecoveryInSecNInputMaximum interval (in seconds) to wait before attempting to reconnect to Azure Service Bus in case of a connection failure. After each attempt, the binding waits a random number of seconds, increasing every time, between the minimum and the maximum. Default: 300 (5 minutes)600
lockRenewalInSecNInputDefines the frequency at which buffered message locks will be renewed. Default: 20.20
maxActiveMessagesNInputDefines the maximum number of messages to be processing or in the buffer at once. This should be at least as big as the maximum concurrent handlers. Default: 12000
maxConcurrentHandlersNInputDefines the maximum number of concurrent message handlers; set to 0 for unlimited. Default: 110
maxRetriableErrorsPerSecNInputMaximum number of retriable errors that are processed per second. If a message fails to be processed with a retriable error, the component adds a delay before it starts processing another message, to avoid immediately re-processing messages that have failed. Default: 1010
publishMaxRetriesNOutputThe max number of retries for when Azure Service Bus responds with “too busy” in order to throttle messages. Defaults: 55
publishInitialRetryIntervalInMsNOutputTime in milliseconds for the initial exponential backoff when Azure Service Bus throttle messages. Defaults: 500500

Azure Active Directory (AAD) authentication

The Azure Service Bus Queues binding component supports authentication using all Azure Active Directory mechanisms, including Managed Identities. For further information and the relevant component metadata fields to provide depending on the choice of AAD authentication mechanism, see the docs for authenticating to Azure.

Example Configuration

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. spec:
  6. type: bindings.azure.servicebusqueues
  7. version: v1
  8. metadata:
  9. - name: azureTenantId
  10. value: "***"
  11. - name: azureClientId
  12. value: "***"
  13. - name: azureClientSecret
  14. value: "***"
  15. - name: namespaceName
  16. # Required when using Azure Authentication.
  17. # Must be a fully-qualified domain name
  18. value: "servicebusnamespace.servicebus.windows.net"
  19. - name: queueName
  20. value: queue1
  21. - name: ttlInSeconds
  22. value: 60

Binding support

This component supports both input and output binding interfaces.

This component supports output binding with the following operations:

  • create: publishes a message to the specified queue

Specifying a TTL per message

Time to live can be defined on a per-queue level (as illustrated above) or at the message level. The value defined at message level overwrites any value set at the queue level.

To set time to live at message level use the metadata section in the request body during the binding invocation: the field name is ttlInSeconds.

  1. curl -X POST http://localhost:3500/v1.0/bindings/myServiceBusQueue \
  2. -H "Content-Type: application/json" \
  3. -d '{
  4. "data": {
  5. "message": "Hi"
  6. },
  7. "metadata": {
  8. "ttlInSeconds": "60"
  9. },
  10. "operation": "create"
  11. }'

Last modified February 7, 2023: Add docs for `pubsub.azure.servicebus.queues` component and update metadata for all other Service Bus components (#3097) (bc48a091)