Business events
Business event is a mechanism that gives you an ability to take actions outside Dynamics 365 Finance and Operations apps in response to a business event that occurs in Finance and Operations. You can find all the information about Business events here.
Additionally, if you are looking for some code samples you can visit this page.
Now we are going to take a look at an example of interaction between business event in Finance and Operations and Azure Service Bus Queue.
Business events and Azure Service Bus
For the security reasons Microsoft recommends storing connection strings outside your applications. Therefore, they provide an Azure Key Vault drive for such purposes.
All you need is to give your application the correct access to the keys, secrets, certificates.
Here is a list of the actions that you must execute to create Azure Service Bus Queue and connect Business event to it:
Create a new Service Bus namespace


NOTE
If you select the Basic pricing tier, you can create only queues. To create topics, you must select the Standard pricing tier.

Also, you should specify valid and readable Namespace name for your Service Bus.
Then press Review+Create button and wait for the deployment of the resource.


Create a new Service Bus queue



Create a new key vault





Register a new application
In this procedure, you will register a new application with Azure AD, and give it read and retrieve access to key vault secrets. Finance and Operations will then use this application to retrieve Service Bus secrets.










Configure a Business Events endpoint


Consume a business event
In the current scenario we will just call send method for the business event directly from runnable class:


After you activate a business event that uses the new Service Bus endpoint, the application sends a test message to verify that the configuration is accurate and to cache the connection.



If you want to change connection for a different Service Bus queue, click Change Connection.


Next, you must enter the schema of the contract that is received from the application. The application only provides a sample payload. However, you can use a capability of Azure Logic Apps to generate a schema from a payload.



