MSBA-279 · Lesson 6 of 12 · 21 min

Domain review: extending the platform

▶ Video coming soon A video version of this lesson is on the way.

This was the review Signe had been looking forward to and Wiremu had been dreading. "Thirty skills, thirty-five to forty percent," Rupert said, writing the numbers on the board. "If you are going to over-prepare anything, over-prepare this." Signe had registered every plug-in step in the registrar solution and could draw the pipeline from memory. Wiremu had written the alarm ingest function and the Parcelwise connector code, but had registered exactly one plug-in step, under supervision. They agreed to teach each other: Signe would take plug-ins and custom APIs, Wiremu would take Azure Functions and authentication, and they would do flows together.

The third domain, Extend Microsoft Power Platform, has five objective groups: create a Dataverse plug-in (11 skills), perform operations by using platform APIs (7), process workloads by using Azure Functions (3), configure Power Automate cloud flows and Copilot Studio workflows (5), and build Microsoft Foundry agents that integrate with Power Platform (4). This lesson reviews the first four. The Foundry group, which is new, has its own lesson, lesson 8. The material was taught in Extending the Platform: Plug-ins, Custom APIs and Connectors (MSBA-272) and Integrating Power Platform with Other Systems (MSBA-273).

The event execution pipeline

Every Dataverse operation is a message, such as Create, Update, Delete, Retrieve or a custom API, processed through the event execution pipeline. Plug-ins are registered as steps on a message, a table and a stage. The stage decides what the plug-in can do.

The event execution pipeline. A request enters PreValidation, stage 10, outside the database transaction. Then PreOperation, stage 20, inside the transaction. Then MainOperation, stage 30, where the platform performs the operation or a custom API plug-in runs. Then PostOperation, stage 40, inside the transaction for synchronous steps. Asynchronous steps run after the transaction commits, through the asynchronous service.
The pipeline stages and where the database transaction begins and ends.
StageNumberIn the transactionTypical use
PreValidation10No, for most messagesReject invalid requests early, before the transaction and before security checks for some operations
PreOperation20YesChange values in the Target before they are saved
MainOperation30YesPlatform operation; only custom API plug-ins run here, set on the API itself
PostOperation40Yes, if synchronousCreate related records, call other operations, set output parameters; asynchronous steps run after commit

Questions on stages are usually decided by one fact. To change a value before it is saved, use PreOperation and modify the Target: no extra update call is needed. To reject a request cheaply, use PreValidation. To create a related record that needs the new record's ID, use PostOperation. To avoid making the user wait for work that can happen later, use an asynchronous PostOperation step. A synchronous step that throws an exception rolls back the whole transaction, including the original operation; that is what makes a PreOperation or PostOperation validation effective.

Execution context, images and the Organization service

A plug-in implements IPlugin with a single Execute method that receives an IServiceProvider. From it the plug-in gets the IPluginExecutionContext, the ITracingService and the IOrganizationServiceFactory. The context tells the plug-in what is happening: MessageName, PrimaryEntityName, Stage, Depth, UserId and InitiatingUserId, InputParameters (including Target), OutputParameters, PreEntityImages, PostEntityImages and SharedVariables.

Context propertyUse
InputParameters["Target"]The Entity being created or updated, or the EntityReference for Delete; on Update it contains only changed columns
PreEntityImages / PostEntityImagesSnapshots of columns before and after the operation, registered on the step with an alias
DepthHow deep the call chain is; used to detect recursion when a plug-in triggers itself
UserId / InitiatingUserIdThe user the step runs as, and the user who started the operation
SharedVariablesPass values between steps in the same pipeline
OutputParametersResults returned to the caller, such as a custom API's response properties

Images answer the most common Update question. On Update, the Target contains only the columns that changed. If the plug-in needs a column that did not change, it reads it from a pre-image registered on the step, not by retrieving the record again. Pre-images are not available on Create, because there is no "before". Post-images are available only in PostOperation, and not on Delete. Images should include only the columns the plug-in needs.

Operations inside a plug-in use the Organization service from the factory. CreateOrganizationService with the context's UserId runs as the step's user; with null it runs as the SYSTEM user, which bypasses the caller's privileges and should be used deliberately. Plug-ins must not call the Dataverse Web API over HTTP from inside the sandbox; they use the Organization service, which runs inside the same transaction. Errors meant for the user are thrown as InvalidPluginExecutionException with a clear message.

The standard opening of a plug-in: services from the provider, a safe Target check, and a pre-image fallback for a column that did not change.
public void Execute(IServiceProvider serviceProvider)
{
    var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    var trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
    var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    var service = factory.CreateOrganizationService(context.UserId);

    if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity target)) return;
    var pre = context.PreEntityImages.Contains("pre") ? context.PreEntityImages["pre"] : null;

    var status = target.GetAttributeValue<OptionSetValue>("lcc_status") ?? pre?.GetAttributeValue<OptionSetValue>("lcc_status");
    trace.Trace("Status {0}, depth {1}", status?.Value, context.Depth);
}

Performance, registration and custom APIs

Plug-in performance questions come down to a short list. Synchronous plug-ins and the operation they belong to must finish within two minutes. Each synchronous plug-in should run quickly, in a couple of seconds at most, or move to an asynchronous step or an Azure Function. Register steps with filtering attributes on Update so they fire only when relevant columns change. Retrieve only the columns needed. Avoid recursion by filtering and by checking Depth. Do not use parallel threads or hold state in static fields, because plug-in instances may be cached and reused.

Steps are registered with the Plug-in Registration Tool, which can be started with pac tool prt, or deployed from the CLI as plug-in packages. Registration sets the assembly or package, the step's message, table, stage, mode (synchronous or asynchronous), filtering attributes, images and the user context. The tool also registers service endpoints and webhooks, which lesson 7 covers.

A custom API defines a new Dataverse message with a unique name, typed request parameters and response properties. Key properties include binding type (global, bound to a table, or bound to a table collection), whether it is a function (called with GET, with no side effects, and requiring at least one response property) or an action, the allowed custom processing step type (none, asynchronous only, or synchronous and asynchronous), an optional execute privilege name to restrict who can call it, and whether it is private. The main logic is a plug-in set on the custom API itself, which runs in MainOperation without a registered step. Some properties, such as whether the API is a function, cannot be changed after creation.

Custom API propertyWhat it controls
Binding typeGlobal, or bound to one row or a collection of a table
Is functionFunction (GET, no data changes) or action (POST); cannot be changed later
Allowed custom processing step typeWhether others can register steps on the message: none, async only, or sync and async
Execute privilege nameA privilege the caller must have to call the API
Is privateHides the API from metadata so only its owner's code uses it
Plug-in typeThe plug-in that implements the main operation

Business events let a Dataverse operation be published as an event that subscribers can listen to, such as a Power Automate flow with the "When an action is performed" trigger or a registered service endpoint. A custom API can be marked so that it is a business event, and catalogs organize business events for makers. The fourth new plug-in skill is managed identity for plug-ins: a plug-in assembly or package is linked to a managed identity record that points to a user-assigned managed identity or app registration with a federated credential, and the plug-in acquires tokens for Azure resources through a managed identity service rather than storing secrets. The assembly must be signed for this.

Platform APIs

This group has seven skills: the Web API, the Organization service, API limit retry policies, optimizing for performance and bulk operations, OAuth authentication, background operations, and the Dataverse SDKs for .NET and Python.

TopicFacts to know
Web APIOData v4 over HTTPS; select, filter, orderby, expand and top query options; pages of up to 5,000 rows with an @odata.nextLink; If-Match for optimistic concurrency; functions with GET and actions with POST; batch requests with change sets for transactions
Organization serviceIOrganizationService with Create, Retrieve, RetrieveMultiple, Update, Delete and Execute; ServiceClient in the .NET SDK for external code
Service protection limitsPer user per web server over a sliding window of 300 seconds: 6,000 requests, 1,200 seconds of execution time, 52 concurrent requests; exceeding returns 429 with Retry-After
Retry policyWait for the Retry-After duration, then retry; the .NET ServiceClient retries automatically; reduce parallelism rather than retrying faster
Bulk operationsCreateMultiple, UpdateMultiple, UpsertMultiple, and DeleteMultiple for elastic tables; ExecuteMultiple up to 1,000 requests; optional bypass of custom plug-in logic for trusted loads
OAuthDelegated flows for interactive users; client credentials with a certificate, secret or federated credential for server-to-server apps, using an application user in Dataverse
Background operationsPreview: start a custom API asynchronously and get a location to check its status or receive a callback
SDKs.NET: ServiceClient. Python: the PowerPlatform-Dataverse-Client package and its DataverseClient class, authenticating with Azure Identity credentials

Throttling questions follow a pattern. An integration loads data with many parallel threads, starts receiving 429 errors and fails. The right answer reads the Retry-After header and waits, reduces parallelism to what the server recommends, and uses bulk messages such as CreateMultiple to do more per request. The wrong answers are "retry immediately", "add more threads" and "use a different user for each thread to get more quota", the last being a misuse that Microsoft explicitly discourages. Signe's practice import of 30,000 rows in Wiremu Dev had shown the effect: four threads completed in about 23 minutes; eight threads were throttled and slower.

OAuth questions often turn on which flow fits. An interactive app acting for a signed-in user uses a delegated flow and acts with the user's privileges. A nightly integration with no user present uses client credentials as an application user in Dataverse, with a security role that grants only what the integration needs. Application users do not need a licence. A question that says "no user signs in" or "runs unattended" points to client credentials; one that says "only data the user can see" points to delegated access.

Azure Functions

The Azure Functions group has three skills: processing long-running operations, implementing scheduled and event-driven triggers, and authenticating to Power Platform with managed identities. The design idea is simple. Anything that takes longer than a plug-in can, or calls slow external systems, moves outside the Dataverse transaction into a function. A Dataverse event reaches the function through a Service Bus queue or a webhook; a timer trigger runs scheduled work; the function writes results back through the Web API or the SDK.

NeedTriggerNotes
React to a Dataverse change reliablyService Bus trigger on a queue the service endpoint posts toMessages wait if the function is down; dead-letter after repeated failure
React immediately to a change with a simple HTTP endpointHTTP trigger called by a webhookWebhook calls time out after 60 seconds; no buffering if the function is down
Run every nightTimer trigger with a scheduleUse for clean-up, summaries and polling with change tracking
Process a large fileBlob or queue triggerKeep work idempotent so retries are safe

New functions use the isolated worker model; support for the in-process model ended on November 10, 2026. For authentication, a function app with a managed identity, registered in Dataverse as an application user, can call Dataverse without any stored secret. That is the answer whenever a question says "without storing credentials" and the caller is an Azure resource. The alarm ingest design at Lumenvale used exactly that: a Service Bus queue, an isolated-worker function with a managed identity, and writes to an elastic table.

Cloud flows and Copilot Studio workflows

The flow group has five skills: complex expressions, flow control and error handling, trigger filters and retry policies, child flows and service principal authentication for the Dataverse connector.

SkillFacts to know
ExpressionsFunctions such as triggerOutputs(), body(), outputs(), items(), coalesce(), if(), equals(), formatDateTime(), addDays(), utcNow(), concat() and json(); reference actions by name
Flow control and errorsGroup actions in scopes; use Configure run after on a following scope to run on failure, timeout or skip; terminate with a status; inspect result() of a scope
Trigger filtersTrigger conditions stop runs that do not meet an expression; on the Dataverse trigger, filter columns and row filters limit when it fires
Retry policiesPer-action retry settings: default, none, fixed interval or exponential, with count and interval
Child flowsReusable logic called with Run a child flow; the child must be in a solution and respond to the parent
Service principalsA Dataverse connector connection that signs in as an application user, so the flow does not depend on a person's account

The classic error handling question shows a flow with a "Try" scope and a "Catch" scope, and asks how to make the Catch scope run only when the Try scope fails. The answer is to configure run after on the Catch scope for "has failed" and "has timed out", not to add a condition inside the Try scope. The classic trigger question asks how to stop a flow from running on every update when only one column matters: set the filter columns on the Dataverse trigger, or add a trigger condition, rather than checking the column in the first action, because a run that starts and stops still counts.

Worked problem

Choosing between a plug-in, a function and a flow

When a work order is closed, the system must (a) reject the close if no completion photo exists, (b) send the requester an email, and (c) post the work order to the contractor's invoicing API, which sometimes takes three minutes to respond. What goes where?

Show solution
  1. (a) must block the close on every path: a synchronous PreOperation plug-in that throws InvalidPluginExecutionException.
  2. (b) is a notification after commit with no strict timing: an asynchronous step or a cloud flow triggered on the status change with filter columns.
  3. (c) exceeds the two-minute limit and calls a slow external API: a service endpoint posting to a Service Bus queue, processed by an isolated-worker Azure Function with retries.

Answer: Plug-in for the rule, flow for the email, queue plus Azure Function for the external API. The same split Lumenvale used for the safety close rule in the facilities solution.

Common mistakes

  • MistakeRetrieving the record again in an Update plug-in to read an unchanged column.

    InsteadRegister a pre-image with the columns needed.

  • MistakeCalling the Web API over HTTP from inside a plug-in.

    InsteadUse the Organization service from the service factory.

  • MistakeRetrying a 429 response immediately with more threads.

    InsteadWait for Retry-After, reduce parallelism and use bulk messages.

  • MistakeChecking a column in the first action to skip unwanted flow runs.

    InsteadUse filter columns or a trigger condition so the flow does not start.

Summary and key terms

  • Domain 3 is worth 35 to 40 percent; plug-ins alone have 11 skills.
  • PreValidation rejects early, PreOperation changes the Target, PostOperation creates related work; only PostOperation can be asynchronous.
  • Use images for unchanged columns, the Organization service inside plug-ins, and custom APIs for reusable messages.
  • Respect service protection limits with Retry-After, bulk messages and sensible parallelism; choose delegated or client credential OAuth by whether a user is present.
  • Use isolated-worker Azure Functions with managed identity for long work, and scopes, trigger filters, child flows and service principals in flows.
Event execution pipeline
The ordered stages through which Dataverse processes a message and runs plug-in steps.
Pre-image
A snapshot of selected columns before the operation, registered on a plug-in step.
Custom API
A developer-defined Dataverse message with typed parameters and a plug-in for its main operation.
Business event
A Dataverse operation published so flows and endpoints can subscribe to it.
Application user
A Dataverse user that represents an app registration or managed identity for server-to-server access.
Retry-After
The header in a 429 response that says how long to wait before retrying.
Scope
A flow action that groups other actions so they can be handled together, for example for errors.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Which stage should change a column value before it is saved?

    Show answer

    PreOperation, by modifying the Target.

  2. What must a custom API function have?

    Show answer

    At least one response property; it is called with GET and makes no data changes.

  3. What authenticates an Azure Function to Dataverse without stored secrets?

    Show answer

    A managed identity registered as an application user.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz