This platform provides developers with efficient ways to manage data, create innovative applications, and automate business processes. Today, we’ll delve into the details of how you can publish a Dataverse event using IServiceEndpointNotificationService.
What is IServiceEndpointNotificationService?
Before we get into the implementation details, let’s first grasp the concept of IServiceEndpointNotificationService. It’s an interface provided by Microsoft Power Platform that allows sending a notification message to an Azure Service Bus or Azure Event Hub from a plugin or custom workflow activity. Microsoft uses IServiceEndpointNotificationService to establish a connection between the Dataverse and Service endpoints.
Publishing a Dataverse Event using IServiceEndpointNotificationService
Dataverse events encompass operations like creating, updating, deleting, and associating records. By publishing these events to IServiceEndpointNotificationService, you can ensure that other services or applications are notified of changes within the common data service.
Now, let’s take a detailed look at how to implement this Service in your application:
public class AccountCreate : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context =
(IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
Entity entity = context.InputParameters[“Target”] as Entity;
if (entity.LogicalName != “account”)
return;
IServiceEndpointNotificationService cloudService =
(IServiceEndpointNotificationService)serviceProvider.GetService(typeof(IServiceEndpointNotificationService));
if (cloudService == null)
return;
string response = cloudService.Execute(new EntityReference(“account”, entity.Id), context);
}
}
In the example provided above, a plugin is created that is triggered when a new account is created in Dataverse. The context of the plugin execution is used along with the target entity (in this case, ‘account’). The IServiceEndpointNotificationService is then used to publish an event (account creation) to a designated service endpoint.
Note: Remember to configure your Dataverse’s Plugin Registration tool to run the plugin on the ‘create’ of ‘account’ and ensure that the Azure Service Bus or Azure Event Hub are correctly configured as service endpoints.
Key Points:
- IServiceEndpointNotificationService helps establish the connection between your application and Service Bus or Azure Event Hubs.
- It enables real-time communication between Dataverse and other external services.
- To use it, your plugin or custom workflow activity should be correctly configured with IServiceEndpointNotificationService.
- Correct configuration of Dataverse’s Plugin Registration tool and Azure Services endpoints is necessary to successfully publish events.
Microsoft Power Platform’s ability to generate events from Dataverse records and publish them to IServiceEndpointNotificationService makes the platform flexible and efficient, enabling businesses to build robust apps and automate various processes. While this discussion only covers the fundamentals, users are urged to explore various other possibilities of what they can achieve using this powerful interface.
Practice Test
True or False: The IServiceEndpointNotificationService is responsible for publishing messages to Azure Service Bus or Azure Event Hubs.
- True
- False
Answer: True
Explanation: This service is an interface that allows the Dataverse to communicate with Azure Service Bus or Azure Event Hubs.
What is the dataverse event published by IServiceEndpointNotificationService commonly known as?
- a. Service event
- b. Plugin event
- c. Endpoint event
- d. Push event
Answer: b. Plugin event
Explanation: Events published by this service are often called plugin events, as they are often used to activate plugins based on message changes.
True or False: You can use IServiceEndpointNotificationService to retract events from Azure services.
- True
- False
Answer: False
Explanation: The IServiceEndpointNotificationService is specifically for publishing events, not retracting them.
What does IServiceEndpointNotificationService publish to Azure services?
- a. Dataverse events
- b. Dataverse databases
- c. Dataverse records
- d. Dataverse queries
Answer: a. Dataverse events
Explanation: The IServiceEndpointNotificationService publishes events from the Dataverse, such as when a record is updated, created, or deleted.
True or False: IServiceEndpointNotificationService only supports synchronous operations.
- True
- False
Answer: True
Explanation: The IServiceEndpointNotificationService runs synchronously, meaning it waits for one operation to finish before starting another.
Which of the following can you use IServiceEndpointNotificationService with?
- a. Azure Logic Apps
- b. Microsoft Power Automate Flows
- c. Azure Functions
- d. All of the above
Answer: d. All of the above
Explanation: You can use the IServiceEndpointNotificationService to publish Dataverse events to any of these Azure services.
True or False: The IServiceEndpointNotificationService can be accessed only through the CRM Web API.
- True
- False
Answer: False
Explanation: The IServiceEndpointNotificationService can also be accessed through the plugin execution context, not just the CRM Web API.
The IServiceEndpointNotificationService publishes messages in which format?
- a. XML
- b. JSON
- c. CSV
- d. SQL
Answer: b. JSON
Explanation: The IServiceEndpointNotificationService publishes messages in JSON format which are easier to handle and parse.
True or False: IServiceEndpointNotificationService can only publish events related to record changes.
- True
- False
Answer: False
Explanation: While many events it publishes are related to record changes, it can also publish events related to other changes in the Dataverse.
True or False: You can use the IServiceEndpointNotificationService to publish messages to Azure Event Grid.
- True
- False
Answer: False
Explanation: IServiceEndpointNotificationService currently does not support Azure Event Grid, it only supports Azure Event Hubs or Azure Service Bus.
What type of operations can IServiceEndpointNotificationService perform?
- a. Create
- b. Read
- c. Update
- d. Delete
Answer: c. Update
Explanation: IServiceEndpointNotificationService is able to perform update operations on event notifications.
Interview Questions
What is IServiceEndpointNotificationService in the context of Microsoft Power Platform?
IServiceEndpointNotificationService is an interface in the Microsoft.Xrm.Sdk Assembly that is used to send a request to a service endpoint. This is especially useful when publishing a Dataverse event.
How is IServiceEndpointNotificationService typically used with Microsoft Dataverse?
IServiceEndpointNotificationService allows developers to send asynchronously a message to the Azure Service Bus. This happens whenever a Dataverse event, such as create, update, or delete, is performed, allowing other applications to react to these events.
What does the “Send” method in the IServiceEndpointNotificationService interface do?
The “Send” method is used to send an execute request to a service endpoint. The request is sent asynchronously.
Is an internet connection always required for IServiceEndpointNotificationService to work?
Yes, a reliable internet connection is required for IServiceEndpointNotificationService to work, because it is used for communicating with a service endpoint over the internet.
What is the return type of the “Send” method from the IServiceEndpointNotificationService interface?
The “Send” method returns a service response that contains a string which can be used to verify whether the service endpoint received the execute request.
What are the parameters for the “Send” method in the IServiceEndpointNotificationService interface?
The “Send” method takes two parameters – ExecutionContext and Entity.
What does the ExecutionContext parameter represent in the “Send” method of IServiceEndpointNotificationService?
ExecutionContext represents the current runtime environment. It includes details about the current operation, user, organization, business unit, and data.
What does the Entity parameter represent in the “Send” method of IServiceEndpointNotificationService?
The Entity parameter is used to represent the entity instance that the request is executing against.
Where can you find the IServiceEndpointNotificationService interface in Microsoft Power Platform Developer tools?
The IServiceEndpointNotificationService interface is found in the Microsoft.Xrm.Sdk Assembly.
Can I send multiple requests simultaneously to IServiceEndpointNotificationService?
Yes, multiple requests can be sent simultaneously through IServiceEndpointNotificationService as it supports asynchronous method invocation.
Can IServiceEndpointNotificationService be used with all versions of Microsoft Power Platform?
No, IServiceEndpointNotificationService can only be used with versions of Microsoft Power Platform that support service endpoints.
What is a service endpoint in relation to IServiceEndpointNotificationService?
In the context of the IServiceEndpointNotificationService interface, a service endpoint is a specific URL where a service can be accessed and with which the interface communicates.
What data type is the ‘trace’ parameter in the ‘Send’ method of IServiceEndpointNotificationService?
The ‘trace’ parameter in the ‘Send’ method of IServiceEndpointNotificationService is of type ITracingService.
What happens when a call to ‘Send’ method of IServiceEndpointNotificationService fails?
When a call to the ‘Send’ method in ‘IServiceEndpointNotificationService’ fails, an exception is thrown.
Can you modify the execution pipeline within IServiceEndpointNotificationService?
While you are executing within IServiceEndpointNotificationService, you cannot make any changes to the execution pipeline. This helps maintain consistency and avoids potential conflicts.