Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 2.44 KB

servicebus.md

File metadata and controls

83 lines (63 loc) · 2.44 KB

Service Bus Trigger

Azure Functions Service Bus trigger lets you listen on Azure Service Bus. Full documentation can be found on azure.com.

Service Bus Events

Service Bus Queue Trigger

This setup specifies that the hello function should be run when a new Service Bus Queue item appears on the queue "hello".

Here's an example:

# serverless.yml

functions:
  example:
    handler: handler.hello
    events:
      - serviceBus:
        x-azure-settings:
            name: item #<string>, default - "mySbMsg", specifies which name it's available on `context.bindings`
            queueName: hello #<string>, specifies the queue name to listen on
            accessRights: manage #<enum manage|listen>, specifies the permission to use when listening on the queue (manage will create queue if not exists)
            connection: ServiceBusConnection #<string>, environment variable which contains Service Bus Namespace Connection String
// handler.js

'use strict';

module.exports.hello = function(context, item) {
  context.log("Received item: ${item}");
  context.done();
};

Service Bus Topic Trigger

This setup specifies that the hello function should be run when a new Service Bus Topic item appears on the subscription "hello".

Here's an example:

# serverless.yml

functions:
  example:
    handler: handler.hello
    events:
      - serviceBus:
        x-azure-settings:
            name: item #<string>, default - "mySbMsg", specifies which name it's available on `context.bindings`
            topicName: "hello" #<string>, topic to listen on
            subscriptionName: "hello" #<string>, subscription to listen on
            connection: ServiceBusConnection #<string>, environment variable which contains Service Bus Namespace Connection String
// handler.js

'use strict';

module.exports.hello = function(context, item) {
  context.log("Received item: ${item}");
  context.done();
};