Tag Archives: Power Automate

When to Use Power Automate vs Azure Functions in Power Platform Solutions

One of the most common patterns I’ve seen in Power Platform projects is defaulting to Power Automate for almost everything.

While Power Automate is incredibly powerful, using it for the wrong scenarios can lead to performance issues, complex maintenance, and limitations that are difficult to overcome.

In a recent solution involving Power Pages, document generation, and backend processing, I had to make several decisions about when to use Power Automate and when to offload logic to Azure Functions. This article shares a practical framework based on those real-world decisions.

The Core Problem

Power Platform provides multiple ways to implement logic:

  • Power Automate (low-code orchestration)
  • Azure Functions (custom code execution)

The challenge is not choosing one over the other, but it’s knowing where each one fits best.

Using the wrong tool in the wrong place often results in:

  • Overly complex flows
  • Performance bottlenecks
  • Difficult debugging and monitoring
  • Limited flexibility for future enhancements

High-Level Comparison

ScenarioPower AutomateAzure Functions
Orchestrating workflowsExcellentNot ideal
Simple data transformationsGoodOverkill
Complex business logicLimitedStrong
Heavy processing (documents, files)StrugglesIdeal
External integrations (custom APIs)Limited controlFull control
Performance-critical operationsSlowerFaster
Maintainability (non-dev teams)EasierRequires dev skills

Real-World Example

In my PDF generation solution:

Power Automate was used for:

  • Receiving requests from Power Pages
  • Selecting the correct template
  • Orchestrating the flow between components
  • Handling configuration and environment differences

Azure Functions was used for:

  • OpenXML document manipulation
  • Accessibility fixes
  • Word-to-PDF conversion using a third-party library

Why this split worked

  • Power Automate handled the process flow and integration
  • Azure Functions handled processing and transformation

Trying to do everything in Power Automate would have resulted in:

  • Complex expressions
  • Limited control over document structure
  • Poor performance

Decision Framework

When designing a solution, I typically evaluate the following:

1. Complexity of Logic

  • If logic is simple → Power Automate
  • If logic involves loops, transformations, or structured processing → Azure Functions

2. Performance Requirements

  • If execution time is not critical → Power Automate
  • If speed and efficiency matter → Azure Functions

3. Maintainability

  • If the solution needs to be maintained by non-developers → Power Automate
  • If it requires structured code and versioning → Azure Functions

4. Scalability

  • Small, event-driven workflows → Power Automate
  • High-volume or compute-heavy workloads → Azure Functions

5. Control and Flexibility

  • Limited customization needed → Power Automate
  • Full control over behaviour and output → Azure Functions

Common Mistakes

1. Overusing Power Automate

Trying to implement everything in flows often leads to:

  • Nested conditions and loops
  • Hard-to-read expressions
  • Difficult troubleshooting

2. Putting Business Logic in the Wrong Layer

Flows should orchestrate—not replace application logic.

Heavy logic in flows can:

  • Reduce clarity
  • Increase maintenance overhead
  • Limit reuse

3. Ignoring Hybrid Approaches

The best solutions often combine both:

  • Power Automate for orchestration
  • Azure Functions for processing

This separation creates cleaner, more maintainable systems.

Recommended Architecture Pattern

A practical pattern that works well:

  1. Power Pages (or another client) triggers a Power Automate flow
  2. Power Automate handles validation and orchestration
  3. Complex processing is delegated to Azure Functions
  4. Results are returned and handled by the flow

This pattern keeps responsibilities clear and avoids overloading any single component.

When to Use Power Automate

Use Power Automate when:

  • You are building workflows and integrations
  • Logic is relatively simple
  • Business users may need to understand or modify the flow
  • You want quick implementation with minimal code

When to Use Azure Functions

Use Azure Functions when:

  • You need full control over logic
  • Processing involves files, documents, or complex transformations
  • Performance is important
  • You need reusable, testable components

Final Thoughts

Choosing between Power Automate and Azure Functions is not about picking a winner it’s about understanding their roles.

Power Automate excels at connecting systems and orchestrating workflows.
Azure Functions excel at executing complex, high-performance logic.

The most effective solutions use both in the layer where they provide the most value.

Getting this balance right can significantly improve performance, maintainability, and scalability in Power Platform solutions.

Share

Fixing Accessibility Issues in Word-to-PDF Conversion (Power Automate + OpenXML)

Generating PDFs in enterprise applications is often treated as a straightforward task until accessibility requirements come into play.

In my previous implementation of an end-to-end PDF generation pipeline using Power Pages, Power Automate, and Azure Functions, one of the biggest challenges was ensuring that the final PDF output was accessible and compliant with WCAG standards.

This article focuses specifically on the accessibility challenges encountered during Word-to-PDF conversion and how they were addressed using OpenXML and post-processing techniques.

The Problem

Using Power Automate’s standard approach:

  • Populate Word Template
  • Convert Word Document to PDF

…produces visually correct documents, but accessibility is often compromised.

Common Issues Observed

  • Lists rendered as plain paragraphs instead of structured lists
  • Checkboxes appearing as static symbols with no semantic meaning
  • Screen readers failing to interpret grouped content correctly
  • Loss of tagging and logical reading order in the final PDF

For users relying on assistive technologies, these issues make the document difficult—or even impossible—to navigate.

Why This Happens

Power Automate’s document generation process focuses primarily on visual rendering, not semantic structure.

Key Limitations

  • Word templates populated via Power Automate do not always preserve semantic elements
  • The built-in PDF conversion process does not guarantee proper tagging
  • Complex controls (like repeating sections) are flattened into static content
  • Accessibility metadata is either lost or never created

In short:
👉 The output looks right, but it isn’t structured correctly.

The Approach

To solve this, I introduced a post-processing step using an Azure Function.

Updated Flow

  1. Power Automate generates the Word document
  2. The document is sent to an Azure Function
  3. OpenXML is used to modify the document structure
  4. The updated document is converted to PDF using a library that supports accessibility
  5. The final PDF is returned to the client

This approach shifts control from “template-only” to full document manipulation.

Key Fixes Implemented

1. Converting Plain Text to Structured Lists

Problem
Bullet points generated via templates were interpreted as plain text by screen readers.

Solution
Using OpenXML:

  • Identify sections representing lists
  • Replace text-based bullets with proper list elements
  • Ensure correct numbering or bullet hierarchy

Result
Screen readers can now:

  • Recognize lists
  • Navigate between items
  • Announce the structure properly

2. Improving Checkbox Representation

Problem
Checkboxes were rendered as symbols (e.g., ☑ or ☐), with no semantic meaning.

Solution

  • Detect checkbox placeholders in the document
  • Replace them with structured representations
  • Ensure consistent labelling and context

Result
Users relying on assistive technologies can understand:

  • Whether an option is selected
  • What the option represents

3. Restoring Document Structure

Problem
Sections like grouped answers or repeated data lost their logical hierarchy.

Solution

  • Reorganize document elements using OpenXML
  • Apply consistent heading and grouping patterns
  • Maintain a logical reading order

Result

  • Improved navigation for screen readers
  • Better alignment with accessibility standards

4. Ensuring Proper PDF Conversion

Problem
Even with a well-structured Word document, conversion tools can break accessibility.

Solution

  • Use a PDF conversion library that supports accessible output
  • Ensure tagging and structure are preserved during conversion

Result

  • Final PDF retains semantic structure
  • Compatible with screen readers and accessibility tools

Key Lessons Learned

1. Accessibility Is Not Automatic

Even if your source document looks structured, it doesn’t mean accessibility is preserved.

You must explicitly:

  • Define structure
  • Validate output
  • Test with assistive tools

2. Word Templates Have Limits

They are useful for:

  • Layout
  • Simple data binding

But not for:

  • Complex structure
  • Accessibility-critical elements

3. Post-Processing Is Essential

OpenXML provides the flexibility needed to:

  • Modify document structure
  • Enforce consistency
  • Apply accessibility rules programmatically

4. Testing Is Critical

Accessibility should be validated using:

  • Screen readers
  • Keyboard navigation
  • Accessibility checkers

Relying only on visual inspection is not enough.

When to Use This Approach

This method is especially useful when:

  • Accessibility compliance is required (e.g., WCAG)
  • Documents contain structured content (lists, forms, checkboxes)
  • Output must be consumed by a wide range of users
  • Standard Power Automate capabilities are insufficient

Final Thoughts

Accessibility is often treated as an afterthought in document generation—but it shouldn’t be.

By introducing a post-processing step with OpenXML and using the right PDF conversion tools, it’s possible to transform a basic document pipeline into an accessible, enterprise-grade solution.

If you’re working with Power Automate and generating documents for real users, investing in accessibility early will save significant effort and deliver a much better experience.

Share

End-to-End PDF Generation in Power Pages Using Power Automate and Azure Functions

In many enterprise scenarios, generating documents is not just about producing a PDF. It’s about producing a structured, accessible, and reliable output that integrates seamlessly with existing systems.

In a recent project, I implemented a complete PDF generation pipeline triggered from Power Pages, orchestrated through Power Automate, and finalized using an Azure Function for advanced document processing.

This article walks through the architecture, key decisions, and lessons learned from building this solution.

The Problem

The requirement seemed straightforward at first:

  • Generate a PDF from a submission in Power Pages
  • Support multiple submission types and languages
  • Ensure accessibility compliance
  • Allow triggering from both Power Pages and Dynamics 365

However, standard approaches quickly showed limitations, especially around formatting and accessibility.

Why the Standard Approach Falls Short

Using Power Automate alone (Word templates + Convert to PDF action) introduces several issues:

  • Flattened content (checkboxes and structured elements become plain text)
  • Limited support for repeating sections (especially nested data)
  • Accessibility issues (screen readers interpret content incorrectly)
  • Loss of semantic structure in the final PDF

For basic documents, this works. For enterprise-grade and accessibility-compliant outputs, it doesn’t.

Solution Overview

To address these limitations, I designed a hybrid architecture combining Power Platform with Azure Functions.

High-Level Flow

  1. Power Pages triggers a Power Automate flow via JavaScript
  2. The flow receives parameters (RecordId, Language)
  3. A core subflow determines the correct Word template
  4. The template is populated dynamically
  5. The document is sent to an Azure Function
  6. Azure Function applies OpenXML fixes and converts to PDF
  7. Base64 PDF is returned and downloaded by the client

Architecture Breakdown

1. Power Pages (Frontend Trigger)

A JavaScript call triggers the flow using an HTTP endpoint:

  • Passes parameters like RecordId and Language
  • Supports multilingual document generation
  • Also reusable from Dynamics 365 via a ribbon button
  • The request first goes through built-in Power Pages security checks before invoking the backend flow

This keeps the frontend lightweight and delegates processing to backend services.

2. Power Automate (Orchestration Layer)

Two flows are used:

  • Portal Flow (entry point)
  • Core Flow (processing logic)

Responsibilities include:

  • Selecting the correct Word template based on submission type and language
  • Populating the template using dynamic data
  • Handling environment-specific configuration
  • Calling the Azure Function using Entra ID and OAuth for secure authentication
  • Ensuring that requests coming from Power Pages are validated through the portal flow before reaching the core processing logic

Templates are stored in a service account OneDrive, ensuring consistency across environments.

3. Word Template Strategy

Templates were designed using:

  • Plain text content controls
  • Repeating section controls for tabular data
  • Placeholder tokens for calculated values (e.g., totals)

However, due to Power Automate limitations:

  • Complex nested structures were avoided
  • Some formatting was deferred to post-processing

4. Azure Function (The Critical Piece)

This is where the real transformation happens.

The Azure Function:

  • Receives the generated Word document
  • Uses OpenXML to:
    • Fix bullet lists (convert plain text into structured lists)
    • Improve checkbox representation
    • Restore semantic structure for accessibility
  • Converts the document to PDF using a third-party library (e.g., Aspose)
  • Returns the PDF as Base64

This step ensures the final output is:

  • Structurally correct
  • Accessible
  • Visually consistent

5. Response Handling

The flow returns a Base64-encoded PDF to the frontend.

On the client side:

  • JavaScript immediately triggers a download
  • No intermediate storage required

This results in a seamless user experience.

Key Design Decisions

Separation of Concerns

  • Power Automate handles orchestration
  • Azure Function handles transformation and conversion

This keeps each component focused and maintainable.

Accessibility First

Instead of fixing accessibility after generation, the solution embeds it into the pipeline:

  • Structured lists instead of plain text
  • Proper handling of semantic elements
  • Screen-reader-friendly output

Reusability Across Channels

The same backend logic supports:

  • Power Pages (external users)
  • Dynamics 365 (internal users)

This avoids duplication and ensures consistency.

Lessons Learned

1. Power Automate Is Not Enough for Complex Documents

It’s great for orchestration, but limited for document fidelity and accessibility.

2. Post-Processing Is Essential

Using OpenXML after template population gives full control over structure.

3. Accessibility Requires Intentional Design

You can’t rely on default tools to produce accessible PDFs. You need to actively shape the output.

4. Environment Configuration Matters

Things like:

  • Template storage (OneDrive paths)
  • Azure Function endpoints
  • Authentication setup

…must be carefully managed across Dev, QA, UAT, and Prod.

When to Use This Approach

This architecture is ideal when:

  • Documents must be accessible (WCAG compliant)
  • Output structure matters (lists, tables, checkboxes)
  • Templates vary by language or type
  • The solution must scale across multiple environments

Final Thoughts

What started as a simple “generate PDF” requirement quickly evolved into a full document processing pipeline.

By combining Power Platform with Azure Functions, it’s possible to go beyond basic automation and deliver enterprise-grade, accessible, and maintainable document solutions.

If you’re working with Power Pages or Dynamics 365 and need reliable document generation, this approach is worth considering.

Share