Azure Service Bus Component
Interact with message queues and publish-subscribe topics (in a namespace)
Component key: azureServiceBusDescription
Azure Service Bus is a fully managed enterprise message broker with message queues and publish-subscribe topics (in a namespace).
Connections
Connection String
The Connection String authentication method is required for any integrations using the following actions:
- Send Messages from Queue
- Receive Messages from Queue
Additionally, in an integration, ensure when using these actions, the connection is configured to the Connection String authentication type.
Creating a new namespace automatically generates an initial Shared Access Signature (SAS) policy with primary and secondary keys, and primary and secondary connection strings that each grant full control over all aspects of the namespace. See Service Bus authentication and authorization for information about how to create rules with more constrained rights for regular senders and receivers.
A client can use the connection string to connect to the Service Bus namespace. To copy the primary connection string for your namespace, follow these steps:
- On the Service Bus Namespace page, select Shared access policies on the left menu.
- On the Shared access policies page, select RootManageSharedAccessKey.
In the Policy: RootManageSharedAccessKey window, select the copy button next to Primary Connection String, to copy the connection string to your clipboard for later use. Paste this value into the connection configuration of your Prismatic integration.
OAuth 2.0
Azure Service Bus uses OAuth 2.0 Authentication to authenticate the security principal (a user, a group, or service principal) running the application. Create and Register your Microsoft application with an Azure AD tenant. For more information refer to https://learn.microsoft.com/en-us/azure/service-bus-messaging/authenticate-application
The first step in using Azure AD to authorize Service Bus entities is registering your client application with an Azure AD tenant from the Azure portal
Menu > All Services > Azure Active Directory
- Select Add > App registration
- Name the App and set the Supported Account types to 'Accounts in any organizational directory (Any Azure AD directory - Multitenant)'.
- In Redirect URI set the first field to “Web”. In the second field enter https://oauth2.prismatic.io/callback and select Register.
Create a client Secret
- Navigate to your app registration in the Azure portal if you aren't already on the page.
- Select Certificates & secrets on the left menu.
- Under Client secrets, select New client secret to create a new secret.
Set the Permissions to the Service Bus API
- If your application is a console application, you must register a native application and add API permissions for Microsoft.ServiceBus to the required permissions set. Native applications also need a redirect-uri in Azure AD, which serves as an identifier; the URI doesn't need to be a network destination. Use
https://servicebus.microsoft.com
for this example, because the sample code already uses that URI.
Assign Azure roles using the Azure portal
- Assign one of the Service Bus roles to the application's service principal at the desired scope (Service
- Bus namespace, resource group, subscription). For detailed steps, see Assign Azure roles using the Azure portal.
Now, configure the OAuth 2.0 connection in Prismatic. Add an Azure Service Bus OAuth 2.0 Connection config variable:
- Use the Application (client) ID value for the Client ID field.
- Use the Client Secret for the same named field.
- If you didn't select Multitenant when creating the Azure application, you will need to replace the Authorize URL and Token URL with ones specific to your tenant.
Save your integration and you should be able to authenticate a user through Azure Service Bus with OAuth 2.0.
Triggers
Webhook
Receive and validate webhook requests from Azure Service Bus for webhooks you configure. | key: subscriptionMessageWebhook
To trigger webhook calls within Service Bus, you need to make use of Azure Event Grid and Logic Apps. Follow these steps to build the webhook integration:
Register Microsoft.EventGrid resource provider to the subscription:
- Navigate to Azure account subscriptions.
- Open the subscription settings.
- Go to Resource Providers.
- Register Microsoft.EventGrid resource.
Create a Service Bus namespace: Create a Service Bus Namespace
Receive messages by using Logic Apps: Receive Messages by Using Logic Apps
Add a step to receive messages from Service Bus via Event Grid: Add a Step to Receive Messages from Service Bus via Event Grid
Add a foreach loop: Add a Foreach Loop
Add an HTTP action to post to Prismatic integration trigger:
- Within the For Each loop, select "Add an action."
- In the "Search connectors and actions" text box, enter "HTTP."
- Select the HTTP action.
- Select POST for Method.
- Add the Prismatic Integration flow URL to the URI Input.
- For the Body, add this expression:
base64ToString(items('For_each')?['ContentData'])
.
- Add another action in the foreach loop to complete the message: Add Another Action in the Foreach Loop to Complete the Message
To test the webhook, send a message to the Topic Subscription using Service Bus Explorer. This should trigger the integration with Prismatic.
Output Example Payload
{
"payload": {
"headers": {
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-US",
"Content-Type": "text/plain; charset=utf-8",
"Host": "hooks.prismatic.io",
"User-Agent": "azure-logic-apps/1.0 (workflow 58fce0896a114cceb9c92a4d07611234; version 08585128901970019172)",
"X-Amz-Cf-Id": "iOiPjKC55qKUNE5Jid-emKKQRPH3TFz7d3O50UcFk-IkV7RuJk1234==",
"X-Amzn-Trace-Id": "Root=1-64a7c5c8-7af54c4a6b77f32e14401234",
"x-ms-action-tracking-id": "ecbd964b-ca88-40dd-977c-5db5129951234",
"x-ms-activity-vector": "IN.0J",
"x-ms-client-request-id": "97110424-b3ec-453a-9e5c-81807df91234",
"x-ms-client-tracking-id": "085851289014160877189743753061234",
"x-ms-correlation-id": "97110424-b3ec-453a-9e5c-81807df91234",
"x-ms-execution-location": "eastus",
"x-ms-tracking-id": "97110424-b3ec-453a-9e5c-81807df91234",
"x-ms-workflow-id": "58fce0896a114cceb9c92a4d07611234",
"x-ms-workflow-name": "subscriptionLogicApp",
"x-ms-workflow-operation-name": "HTTP",
"x-ms-workflow-repeatitem-batch-index": "0",
"x-ms-workflow-repeatitem-index": "0",
"x-ms-workflow-repeatitem-scope-name": "For_each",
"x-ms-workflow-resourcegroup-name": "Prismatic",
"x-ms-workflow-run-id": "085851289014160877179743753061234",
"x-ms-workflow-run-tracking-id": "878c50fd-9ec7-417e-bb06-0eb3e5d21234",
"x-ms-workflow-subscription-id": "782a9e34-9e60-4037-b32e-40b85e601234",
"x-ms-workflow-system-id": "/locations/eastus/scaleunits/prod-55/workflows/58fce0896a114cceb9c92a4d07611234",
"x-ms-workflow-version": "08585128901970011234"
},
"queryParameters": null,
"rawBody": "<data (4 bytes)>",
"body": {
"data": "test",
"contentType": "text/plain; charset=utf-8"
},
"pathFragment": "",
"webhookUrls": {
"Flow 1": "https://hooks.prismatic.io/trigger/WEBHOOK_ID"
},
"webhookApiKeys": {
"Flow 1": ["sample-api-key"]
},
"invokeUrl": "https://hooks.prismatic.io/trigger/WEBHOOK_ID",
"executionId": "SW5zdGFuY2VFeGVjdXRpb25SZXN1bHQ6ZGNhYTAxOTUtOTcwMi00NzAzLWJkZTctMmEwMDIwMWIz1234",
"customer": {
"id": "testCustomerId",
"name": "Test Customer",
"externalId": "testCustomerExternalId"
},
"instance": {
"id": "testInstanceId",
"name": "Test Instance"
},
"user": {
"id": "testUserId",
"email": "testUserEmail@example.com",
"name": "Test User",
"externalId": "testUserExternalId"
}
}
}
Actions
Create or Update Namespaces
Creates or updates a service namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. | key: createOrUpdateNamespaces
Create or Update Queue
Creates or updates a Service Bus queue. This operation is idempotent. | key: createOrUpdateQueue
Create or Update Rules
Creates a new rule and updates an existing rule | key: createOrUpdateRules
Create or Update Subscription
Creates a topic subscription. | key: createOrUpdateSubscription
Create or Update Topic
Creates or updates a topic in the specified namespace. | key: createOrUpdateTopic
Delete Namespace
Deletes an existing namespace. This operation also removes all associated resources under the namespace. | key: deleteNamespace
Delete Queue
Deletes a queue from the specified namespace in a resource group. | key: deleteQueue
Delete Rule
Deletes an existing rule. | key: deleteRule
Delete Subscriptions
Deletes a subscription from the specified topic. | key: deleteSubscriptions
Delete Topic
Deletes a topic from the specified namespace and resource group. | key: deleteTopic
Get Namespaces
Gets a description for the specified namespace. | key: getNamespaces
Get Queue
Returns a description for the specified queue. | key: getQueue
Get Rule
Retrieves the description for the specified rule. | key: getRule
Get Subscriptions
Returns a subscription description for the specified topic. | key: getSubscriptions
Get Topic
Gets all the topics in a namespace | key: getTopic
List Namespaces
Gets all the available namespaces within the subscription, irrespective of the resource groups. | key: listNamespaces
List Namespaces By Resource Group
Gets the available namespaces within a resource group. | key: listNamespacesByResourceGroup
List Queues
Gets the queues within a namespace. | key: listQueues
List Rules
List all the rules within given topic-subscription | key: listRules
List Subscriptions
List all the subscriptions | key: listSubscriptions
List Subscriptions By Topic
List all the subscriptions under a specified topic. | key: listSubscriptionsByTopic
List Topics By Namespace
Gets all the topics in a namespace | key: listTopicsByNamespace
Raw Request
Send raw HTTP request to Azure Service Bus | key: rawRequest
Receive Messages from Queue
Receive messages from a queue. Receive messages from a queue will remove the message from the queue. | key: receiveMessagesFromQueue
Send Message to Queue
Send a single message to a queue. | key: sendMessageToQueue
Send Multiple Messages to Queue
Send multiple plain text messages to a queue. | key: sendMessagesToQueue