Enterprise D365 Customer Service Architecture Series · Principal Software Engineering · Extension Strategy

The architectural question: When should business logic run inside Dataverse, when should it run in Power Automate, and when should it be implemented as an Azure service?

This decision can have a significant impact on performance, maintainability, transaction consistency, security, operational complexity, and long-term cost.

A common mistake is to select a technology based on familiarity: developers choose plugins because they know C#, makers choose Power Automate because it is convenient, and architects choose Azure Functions because they want a separate service.

A better approach is to start with the business requirement, determine the execution and consistency guarantees it needs, and then select the smallest appropriate architectural mechanism.

This article develops a practical decision framework for senior engineers and solution architects working with Dynamics 365 Customer Service and Microsoft Power Platform.

1. The problem: three technologies, overlapping responsibilities

Consider a fictional enterprise customer service application.

When an agent creates a case, the solution must:

  • Validate mandatory business information.
  • Determine the appropriate case classification.
  • Assign a queue or trigger routing.
  • Notify the customer.
  • Retrieve information from an external business system.
  • Record the result and expose the status to the agent.
  • Produce an audit trail that supports operational investigations.

It is tempting to put all these operations into a single plugin, a collection of cloud flows, or one Azure Function.

All three approaches can execute application logic, but they have different execution models and operational characteristics.

The critical distinction is not simply low-code versus pro-code. It is where the logic executes, what guarantees it requires, what dependencies it introduces, and who must operate it.

A rule that must reject an invalid case update before the transaction commits has different requirements from a notification that can be delivered a few seconds later. Neither should be implemented using the same mechanism merely for consistency of tooling.

2. Understand the execution models

Dataverse plugins

Dataverse Plugin vs Power Automate: Transactional Logic vs Process Automation | Nishi Modgil posted on the topic | LinkedIn

Server-side, event-driven execution

Plugins participate in the Dataverse event pipeline. Depending on their registration and execution stage, they can validate operations or execute logic associated with record changes.

Power Automate

3 Silent Killers of Power Automate Performance (And How to Fix Them) | by The Cloud Architect | Mar, 2026 | Medium

Declarative workflow and orchestration

Cloud flows coordinate triggers, conditions, approvals, connector operations, and asynchronous business processes. They are particularly useful when business teams need a transparent, governable workflow.

Azure Functions

Azure Files performance improvements video | John Savill posted on the topic | LinkedIn

Custom compute and integration

Azure Functions execute code in response to HTTP requests, messages, timers, and other supported triggers. They suit custom integration logic, transformations, background processing, and independently operated workloads.

These are not mutually exclusive technologies. A mature architecture can use all three, provided each has a clear responsibility and there are no unnecessary overlapping business rules.

3. Decision matrix: which mechanism should you choose?

Use this matrix as an initial architecture review tool, then validate the choice against transaction semantics, supported platform behavior, licensing, and operational requirements.

RequirementPreferred starting pointWhy
Reject an invalid case update before it commitsSynchronous plugin or supported native validationEnforces a server-side invariant at the appropriate transaction boundary.
Set a derived field during a Dataverse operationNative capability or PreOperation pluginAvoids an unnecessary extra update and can keep the change within the current operation.
Send a customer notification after a case is createdPower Automate or an asynchronous integration serviceThe notification usually does not need to block case creation.
Run a multi-step approval workflowPower AutomateProvides declarative orchestration and visibility into workflow steps.
Expose a reusable business operation through DataverseDataverse custom APIDefines an operation contract for supported callers.
Call several enterprise APIs and normalize their responsesAzure Function or .NET integration serviceProvides explicit control over contracts, resilience, dependencies, and tests.
Process a high-volume stream of independent messagesService Bus with an appropriate consumerDecouples producers and consumers and supports durable messaging patterns.
Coordinate a long-running operation with a visible statusAsynchronous workflow with durable stateAllows the user to see pending progress without holding an interactive request open.
Apply a simple condition-based process that makers can maintainNative capability or Power AutomateAvoids custom infrastructure when the platform satisfies the requirements.

Important: An asynchronous plugin, a Power Automate cloud flow, and an Azure Function are not interchangeable merely because all can run after a record change. Their triggers, execution limits, transaction semantics, retry behavior, identity models, and operational responsibilities differ.

4. Dataverse plugins: use them for platform-level business invariants

A Dataverse plugin is a custom event handler registered against an operation in the Dataverse event pipeline. It is especially useful when logic must run on the server as part of a supported data operation.

Example: enforcing case resolution rules

Suppose an enterprise requires every case being resolved to have a resolution category and a resolution summary.

The rule must apply whether the update comes from the agent workspace, a Web API client, an import, or another supported caller.

A synchronous PreValidation plugin can reject an invalid operation before the main operation proceeds. The exact transaction behavior depends on whether the step runs for the initial operation or a nested operation. A PreOperation plugin is appropriate when values must be changed within the current transaction.

Illustrative C# code:

using Microsoft.Xrm.Sdk;

public sealed class ValidateCaseResolutionPlugin : IPlugin
{
    public void Execute(IServiceProvider serviceProvider)
    {
        var context = (IPluginExecutionContext)
            serviceProvider.GetService(
                typeof(IPluginExecutionContext));

        if (!string.Equals(
                context.MessageName,
                "Update",
                StringComparison.OrdinalIgnoreCase))
        {
            return;
        }

        if (!string.Equals(
                context.PrimaryEntityName,
                "incident",
                StringComparison.OrdinalIgnoreCase))
        {
            return;
        }

        if (!context.InputParameters.TryGetValue(
                "Target", out var value) ||
            value is not Entity target)
        {
            return;
        }

        // The example assumes a custom choice column
        // named new_casestatus and a custom text column
        // named new_resolutionsummary.
        if (!target.Contains("new_casestatus"))
            return;

        var status = target.GetAttributeValue<OptionSetValue>(
            "new_casestatus");

        if (status?.Value != 100000002)
            return; // Illustrative "Resolved" choice value.

        var summary = target.GetAttributeValue<string>(
            "new_resolutionsummary");

        if (string.IsNullOrWhiteSpace(summary))
        {
            throw new InvalidPluginExecutionException(
                "A resolution summary is required.");
        }
    }
}

This example illustrates the shape of a server-side invariant, not a ready-to-deploy plugin. The schema names and choice value are illustrative. A production implementation must account for partial update payloads: if a required attribute is not present in Target, the plugin may need to retrieve its existing value or use a suitable pre-image to evaluate the resulting record state. The registration must also match the actual Dataverse table and operation semantics.

Plugin engineering rules

  • Keep synchronous execution short and deterministic.
  • Use filtering attributes and pre-images appropriately to avoid unnecessary work.
  • Avoid recursive updates and duplicate step registrations.
  • Implement plugin classes as stateless components.
  • Do not use unsupported parallel execution or batch request patterns inside plugins.
  • Handle exceptions deliberately and provide actionable, safe error messages.
  • Use asynchronous execution when work can safely occur after the originating operation.
  • Do not make a slow external HTTP call part of a synchronous transaction unless the business requirement genuinely justifies the dependency and the design complies with platform constraints.

Microsoft explicitly warns that slow synchronous plugins can degrade the user experience and cause timeouts. It also advises against batch request types within plugin execution.

Architectural rule: A plugin should protect the integrity of a Dataverse operation, not become an unrestricted integration engine.

5. Power Automate: use it for declarative business orchestration

Power Automate is valuable when the business process is naturally expressed as a workflow of triggers, conditions, approvals, notifications, and connector actions.

Consider this scenario:

  1. A case is created.
  2. The case meets a defined escalation condition.
  3. The appropriate manager receives an approval request.
  4. The decision is recorded.
  5. The agent receives a notification.
  6. The case is updated to reflect the outcome.

A cloud flow can make this process easier to understand, maintain, and adjust than a collection of hard-coded branches inside a custom service.

However, a cloud flow is not automatically reliable simply because it is managed by the platform.

Production flow design

For a Dataverse-triggered flow, configure the trigger to run only for relevant tables, events, and columns. Add appropriate trigger conditions and design the workflow to avoid self-triggering loops.

Microsoft documents that Dataverse row triggers can fire on multiple updates and that selected columns determine which update requests trigger a flow. It also documents how connector actions can execute under different user contexts.

Consider the following example:

  • A case is updated to Escalated.
  • A flow sends an escalation notification.
  • The flow updates the case with NotificationStatus = Sent.
  • That update triggers the flow again if the trigger configuration is too broad.

The result can be repeated notifications or unnecessary executions.

Mitigations include filtering the trigger to relevant columns, checking the current business state, separating operational metadata from triggering conditions, and ensuring that the flow’s effects do not repeatedly satisfy its own trigger.

Where Power Automate starts to become difficult

Reconsider the design when the flow accumulates:

  • Complex nested conditions and repeated branches.
  • Extensive custom transformation logic.
  • Several independently versioned API contracts.
  • Complicated retry and reconciliation requirements.
  • Large volumes of correlated messages.
  • A need for extensive unit testing of domain behavior.
  • Tight coupling between several flows that jointly implement one business operation.

These are not automatic reasons to replace Power Automate. They are signals to assess whether a dedicated application service or orchestration component would provide clearer ownership, testability, and operational control.

A useful enterprise pattern is to keep straightforward business workflows in Power Automate while delegating complex integration operations to a governed API or application service.

6. Azure Functions: use them for custom integration and compute

Azure Functions are appropriate when a workload needs custom code, independently managed execution, event-driven processing, or a clear boundary between CRM and enterprise systems.

Imagine a customer service request that requires the integration layer to:

  1. Validate an incoming request contract.
  2. Retrieve data from an authoritative enterprise system.
  3. Transform the response into a CRM-facing model.
  4. Handle throttling and transient errors.
  5. Record the outcome.
  6. Return a result or publish a status update.

This logic may be better implemented in a .NET application service hosted by Azure Functions than inside a plugin or a large cloud flow.

Recommended Clean Architecture structure

For a solution with multiple integration workloads, use a structure that separates business orchestration from hosting and infrastructure concerns.

src/
  CustomerService.Integration.Functions/
    Functions/
    DependencyInjection/
    Program.cs

  CustomerService.Integration.Application/
    Commands/
    Queries/
    Interfaces/
    Validators/

  CustomerService.Integration.Domain/
    Entities/
    ValueObjects/
    Policies/

  CustomerService.Integration.Infrastructure/
    Dataverse/
    EnterpriseApis/
    Messaging/
    Persistence/
    Observability/

The Functions project is the entry point. It should handle transport-level concerns and delegate application work to the Application layer. The Application layer coordinates the use case through abstractions. The Domain layer holds business concepts and invariants where appropriate. Infrastructure implements external API clients, messaging, persistence, and other technical dependencies.

This structure is not mandatory for a small function with trivial logic. It becomes useful when the solution has meaningful domain behavior, multiple integration endpoints, or a long expected lifespan.

Illustrative HTTP-triggered function

The following example demonstrates delegation to an application service. It intentionally omits the application service implementation and hosting configuration.

public sealed class SubmitRequestFunction
{
    private readonly ISubmitServiceRequest _handler;

    public SubmitRequestFunction(
        ISubmitServiceRequest handler)
    {
        _handler = handler;
    }

    [Function(nameof(SubmitRequestFunction))]
    public async Task<HttpResponseData> Run(
        [HttpTrigger(
            AuthorizationLevel.Function,
            "post")] HttpRequestData request,
        CancellationToken cancellationToken)
    {
        var command = await request.ReadFromJsonAsync<
            SubmitServiceRequestCommand>(
                cancellationToken);

        if (command is null)
        {
            var badRequest = request.CreateResponse(
                HttpStatusCode.BadRequest);

            await badRequest.WriteStringAsync(
                "A valid request body is required.",
                cancellationToken);

            return badRequest;
        }

        var result = await _handler.HandleAsync(
            command, cancellationToken);

        var response = request.CreateResponse(
            result.Accepted
                ? HttpStatusCode.Accepted
                : HttpStatusCode.Conflict);

        await response.WriteAsJsonAsync(
            result, cancellationToken);

        return response;
    }
}

This is illustrative Azure Functions .NET isolated-worker code, not a complete production endpoint. A real implementation needs explicit authentication and authorization, contract validation, safe error mapping, input-size limits, telemetry, and a defined idempotency strategy. AuthorizationLevel.Function alone should not be treated as a complete enterprise identity and authorization model.

Azure Functions guidance recommends stateless and defensive functions, controlled dependency usage, monitoring, and integration testing. Hosting plan and concurrency settings should be selected according to workload requirements.

Do not turn every function into a microservice

A separate Function App is justified when there is a meaningful deployment, security, scaling, or operational boundary. It is not necessary for every function endpoint.

Several related functions can share a Function App when they share operational requirements and can be safely deployed and scaled together. Conversely, workloads with very different latency, throughput, access permissions, or failure characteristics may need separate hosting boundaries.

The objective is to isolate the responsibilities that need isolation without multiplying deployment and support overhead unnecessarily.

7. The most important trade-off: transaction consistency

This is where technology selection becomes an architecture decision rather than a coding preference.

Consider a requirement:

A case must not be resolved unless a mandatory resolution summary exists.

A synchronous Dataverse plugin can reject the operation before it commits. The user receives a failure, and the invalid state is not accepted through that operation.

Now consider a different requirement:

When a case is created, notify the customer and retrieve an external fulfillment status.

These actions may not need to finish before the case is saved. If the external service is unavailable, blocking case creation may be worse than accepting the case and processing the work asynchronously.

The difference is the required consistency boundary.

ConcernSynchronous pluginPower AutomateAzure Function
Reject the current Dataverse operationYes, when registered and implemented appropriatelyNo, not as a general post-save row-trigger mechanismNo, not directly from an independent HTTP-triggered function
Participate in the Dataverse transactionSupported synchronous pipeline stages can participateA flow triggered after the row change does not share the originating transactionAn independent function does not share the Dataverse transaction
Wait for external processingPossible, but usually undesirable for slow dependenciesCan orchestrate actions, but may introduce long waitsCan call dependencies, or coordinate asynchronous processing
Durable workflow stateDataverse records and platform capabilities, as appropriateFlow run history and application data, with explicit business state when neededExplicit persistence or messaging is often appropriate
Unit testing complex business logicPossible, though platform interactions require additional testingTests often focus on workflow behavior and integration scenariosStrong fit for unit-testing application services and domain logic

The critical point is that a synchronous plugin can reject or modify the originating Dataverse operation under the appropriate execution conditions. A separate Azure Function or a post-save cloud flow cannot retroactively participate in that original transaction.

For complex cross-system operations, the solution must explicitly handle the absence of a distributed atomic transaction. That may mean an asynchronous process, a state machine, reconciliation, or a saga with appropriate compensation.

8. A practical combined architecture

The strongest design is often not plugin versus Power Automate versus Azure Functions. It is a deliberate combination with clear responsibilities.

Consider a service request that needs validation, downstream fulfillment, and a customer notification.

Power Automate can be added where a human approval or declarative notification workflow provides value. It should not be added merely to make the architecture appear more comprehensive.

For this design to work, the team must define how the integration service is invoked, how the work is durably accepted, and how a completed operation updates Dataverse. A queue-based design may use an outbox or another reliable publication mechanism where needed to avoid losing work between saving business state and publishing a message.

9. Security, resilience, and observability across all three

Technology choice does not remove the need for consistent engineering controls.

Security

For plugins, review execution identity, impersonation, registration, and access to Dataverse data. For Power Automate, govern flow ownership, connection references, connection permissions, and run-only users where applicable. For Azure Functions, use supported identity-based authentication, managed identities for Azure resources, least-privilege access, and secure configuration.

Do not assume that the agent’s permissions automatically govern every operation performed by a flow or application identity. The actual execution identity and authorization path must be understood and tested.

Resilience

For plugins, keep synchronous operations short and avoid unnecessary external dependencies. For flows, configure retries deliberately, control trigger conditions, and make repeated actions safe. For Functions, define timeouts, bounded retries, cancellation behavior, and dependency-specific failure handling.

When a downstream operation has an uncertain outcome, reconcile it using a stable operation reference rather than blindly resubmitting the command.

Observability

Establish a shared operational vocabulary across components:

  • Business operation ID.
  • Correlation ID.
  • Component and dependency name.
  • Outcome and failure category.
  • Processing duration and retry count.
  • Safe, approved business reference.

For example, the team should be able to trace a service request from Dataverse through a flow or plugin, into an Azure service, and onward to the downstream API without exposing sensitive request payloads.

Microsoft’s Dataverse plugin guidance, Power Automate trigger documentation, and Azure Functions best practices provide the implementation-specific foundations for these controls.

10. Anti-patterns that senior architects should challenge

The everything-in-a-plugin design

A synchronous plugin calls multiple external APIs, performs complex transformations, sends notifications, and updates unrelated records. This increases latency, couples CRM availability to external systems, and makes failures harder to recover from.

The flow-for-everything design

Every field update triggers several cloud flows, each of which updates the same records. The result is a difficult-to-trace dependency chain with unnecessary executions, recursion risks, and ambiguous ownership.

The Function App as a dumping ground

A large collection of unrelated endpoints shares the same deployment, permissions, configuration, and scaling settings. A change to one workload can affect another, even when their operational needs differ.

The duplicate business-rule problem

The same rule is implemented independently in a plugin, a cloud flow, and a downstream API. Over time, the implementations diverge, producing inconsistent decisions. Define one authoritative owner and reuse a governed contract where appropriate.

The retry-without-idempotency problem

A request times out, so a flow or function retries the operation without checking whether the downstream action already succeeded. This can create duplicate business effects. Design for safe retries and reconciliation.

11. A senior architect’s decision checklist

Before approving an extension mechanism, ask these questions:

  1. Transaction: Must the originating Dataverse operation be rejected if this rule fails?
  2. Latency: Does the user need a completed result immediately, or is a pending status acceptable?
  3. Ownership: Is this a Dataverse business invariant, a human-centered workflow, or a cross-system application operation?
  4. Dependencies: What happens if an external API is slow, unavailable, or returns an ambiguous result?
  5. Idempotency: Can the operation be safely retried without duplicate business effects?
  6. Security: Which identity executes the work, and what permissions does it have?
  7. Testing: Can the business behavior be tested independently of its hosting mechanism?
  8. Operations: Who monitors failures, handles dead letters, investigates incidents, and performs reconciliation?
  9. ALM: How will changes be versioned, validated, deployed, and recovered?
  10. Complexity: Is the selected technology solving a real requirement, or merely adding infrastructure?

The right answer should be documented in an architecture decision record when the choice materially affects transaction consistency, security, scalability, or operational ownership.

12. The final decision framework

Choose by responsibility, not preference

Choose Dataverse plugins: When server-side validation, transactional invariants, or event-pipeline behavior are essential and native capabilities do not meet the requirement.

Choose Power Automate: When the requirement is a declarative business workflow, approval, notification, or connector-based orchestration with manageable complexity.

Choose Azure Functions: When custom application logic, cross-system integration, independently operated compute, or event-driven processing justifies a separate service boundary.

Combine them deliberately: When different parts of the same business process have genuinely different execution, consistency, and operational requirements.

The most effective architecture is not the one that uses the most technologies. It is the one in which every component has a clearly defined responsibility, every business rule has an authoritative owner, and every failure has a deliberate handling strategy.

That is the difference between implementing a feature and engineering an enterprise platform.

References and further reading