In step 2 to step 4, we added the code to write to the Azure Service Bus using IServiceEndpointNotificationService from the plugin service provider. The method requires an entity reference to our Dynamics 365 service endpoint record, which we resolved using the GUID passed by the plugin configuration.
Finally, the plugin context is passed to the IServiceEndpointNotificationService Execute method.
In step 5, don't forget to sign your assembly, as we have done in the Creating your first plugin recipe of Chapter 4, Server-Side Extensions.
In step 6, we also added a step that triggers synchronously. Generally speaking, registering a synchronous plugin dependent on external resources is not recommended as the external communication might take longer than expected, which might affect user experience and possibly exceed the 2 minutes timeout limitation. However, synchronous steps give you a near real-time integration between Dynamics 365 and consumers listening to incoming messages, whereas asynchronous steps will execute within a few seconds delay depending on the server load.
In step 6, we also added the service endpoint we retrieved in the Getting ready section of this recipe. The passed on configuration may contain other values as well, in which case you will have to write your own methods to extract the values you are after.