How do I send an Azure Service Bus notification when an event occurs?

Prev Next

Providing you are a LUSID user with sufficient access control permissions, you can create a notification to send to Azure Service Bus when a system event you have subscribed to occurs.

For example, you could send a Service Bus message to a queue when the LUSID PortfolioCreated event occurs.

Using the Notification API

Currently, you can create one notification per API call.

Note

You must have already subscribed to the event you want to attach the Azure Service Bus notification to.

Step 1: Supply your Azure credentials in the Configuration Store

Before you can create a notification, you must perform a one-time setup of your Azure credentials in the LUSID Configuration Store.

Create a configuration set containing the following:

Key

Value

namespace

Your Azure Service Bus namespace

queueName

Your Azure Service Bus queue name

tenantId

Your Azure tenant ID

clientId

Your Azure application ID

clientSecret

Your Azure client secret

Read more on how to find these credentials in Azure.

Step 2: Create a notification

Call the CreateNotification API for your LUSID domain, passing in your API access token and the following:

  • The scope and code of the subscription to attach the notification to

  • A unique notificationId

  • A friendly displayName and description

  • A notificationType containing:

    • Type: AzureServiceBus

    • Body: The notification message; you can use attributes of the event in mustache templates to make the text more meaningful with dynamic fields

    • Namespace: The path to the namespace credential in your configuration set from step 1 in the format config://shared/<config-set-scope>/<config-set-code>/namespace

    • QueueName: config://shared/<config-set-scope>/<config-set-code>/queueName

    • TenantId: config://shared/<config-set-scope>/<config-set-code>/tenantId

    • ClientId: config://shared/<config-set-scope>/<config-set-code>/clientId

    • ClientSecret: config://shared/<config-set-scope>/<config-set-code>/clientSecret

For example, to attach an Azure Service Bus notification to a subscription with…

  • Configuration set scope Azure and code ServiceBus

  • Subscription scope PortfolioEvents and code PortfolioCreated

…you might send the following:

curl -X POST "https://<your-domain>.lusid.com/notification/api/subscriptions/PortfolioEvents/PortfolioCreated/notifications"
-H "Authorization: Bearer <your-API-access-token>"
-H "Content-Type: application/json"
-d '{
  "notificationId": "AzureServiceBusNotification1",
  "displayName": "AzureServiceBusNotification",
  "description": "PortfolioCreated notification for Azure Service Bus",
  "notificationType": {
    "Type": "AzureServiceBus",
    "Body": "Portfolio created in scope {{Body.portfolioScope}} with code {{Body.portfolioCode}}",
    "Namespace": "config://shared/Azure/ServiceBus/namespace",
    "QueueName": "config://shared/Azure/ServiceBus/queueName",
    "TenantId": "config://shared/Azure/ServiceBus/tenantId",
    "ClientId": "config://shared/Azure/ServiceBus/clientId",
    "ClientSecret": "config://shared/Azure/ServiceBus/clientSecret"
  }
}'

Note

You can use the notificationId to reference the notification in subsequent API calls.