The business logic challenge
When implementing business logic in Dynamics 365, architects face a critical decision: where should the logic run? The three primary options—Power Automate, Plugins, and Azure Functions—each have distinct characteristics that make them suitable for different scenarios.
Option 1: Power Automate cloud flows
Best for: Low-code automation, external integrations, approval workflows
Strengths
- No code required
- 1,000+ prebuilt connectors
- Built-in approval workflows
- Easy to modify and maintain
- Visual designer for non-developers
- Rapid development
- Always asynchronous
- No transaction support
- Latency (seconds to trigger)
- API call limits apply
- Complex logic becomes difficult
- Additional licensing costs
Ideal use cases
- Sending email notifications on record changes
- Multi-level approval processes
- Integrating with external SaaS applications
- Scheduled data synchronization
Option 2: Dynamics 365 plugins
Best for: Synchronous validation, complex calculations, transaction-critical logic
Strengths
- Synchronous execution
- transaction participation
- lowest latency
- pre-validation capabilities
- no additional licensing
- full access to execution context
- Requires C# development
- 2-minute execution limit
- Sandbox restrictions
- No external HTTP calls (sandbox)
- Harder to debug
- Deployment requires solution
Ideal use cases
- Preventing invalid data from being saved
- Auto-numbering and unique code generation
- Complex field calculations before save
- Cascading updates within the same transaction
Option 3: Azure Functions
Best for: Heavy processing, external API calls, long-running operations
Strengths
- No execution time limits
- Full .NET capabilities
- External API access
- Scalable compute
- Multiple trigger types
- Full debugging support
- Requires Azure subscription
- Additional infrastructure to manage
- Always asynchronous from D365
- No transaction participation
- Requires developer expertise
- Separate deployment pipeline
Ideal use cases
- Complex data transformations and ETL
- Calling external REST APIs with complex authentication
- Batch processing large record sets
- PDF generation and document processing
Comprehensive comparison
| Criteria | Power Automate | Plugins | Azure Functions |
|---|---|---|---|
| Execution mode | Async only | Sync or async | Async (from D365) |
| Latency | Seconds | Milliseconds | Seconds |
| Transaction | No | Yes | No |
| Max duration | 30 days | 2 minutes | Unlimited* |
| External APIs | Yes (connectors) | No (sandbox) | Yes (full access) |
Decision framework
1. Does the logic need to run synchronously?
Yes: Use a plugin. No: Continue to next question
2. Does it need to prevent the save operation?
Yes: Use a plugin (PreValidation or PreOperation). No: Continue
3. Does it require external system integration?
Yes with existing connector: Power Automate. Yes with complex API: Azure Functions
4. Is it heavy computational work or long-running?
Yes: Use Azure Functions
5. Who will maintain this logic?
Business users: Power Automate. Developers: Plugin or Azure Functions
Hybrid architectures
Often the best solution combines multiple approaches:
Plugin + Azure Function
Use a plugin for immediate validation and an Azure Function for heavy background processing
Plugin + Power Automate
Use a plugin for synchronous logic and Power Automate for notifications and approvals
Anti-patterns to avoid
- Using Power Automate for validation: Async flows can't prevent saves
- Plugins calling external APIs: Sandbox restrictions and timeout risks
- Complex business logic in Power Automate: Becomes unmaintainable
- Azure Functions for simple field updates: Over-engineering
- Synchronous plugins for notifications: Unnecessary blocking of users
Conclusion
The choice between Power Automate, Plugins, and Azure Functions isn't about which is 'best'—it's about which is best for your specific scenario. Power Automate excels at low-code integrations and approvals. Plugins are the strongest option for synchronous, transactional logic. Azure Functions provide unlimited flexibility for complex processing. Most enterprise solutions will leverage all three.