
WE HAD A legacy claims system
BUT we don’t wan’t to pay the license anymore
WE NEED TO still print paperwork
BUT our business application generated them before
WE MUST do it securely
{
"Name": "SET-1001-T8B5",
"Settlement": "7BB40F56-8E33-EF11-8E4E-6045BD0D261B"
}
Click and wait
Clunky
Can't share it
Get power automate to make a web page for us
Can that web page present a PDF document
Live Demo 2
content-type : text/html
content-type : text/html
Live Demo 3
Response Headers
Content-Type: application/pdf
Content-Type: application/pdf
Common MIME types - HTTP | MDN (mozilla.org)
Content-Disposition: inline
Content-Disposition: attachment; filename=“filename.pdf”
Content-Disposition: inline
Content-Disposition: attachment; filename="filename.pdf"

Live Demo 4
@{triggerOutputs()[‘queries’]}
@{triggerOutputs()['queries']}
Authenticate by Azure B2C
Reverse Proxy function

FLOW_URL=https://prod-21.uksouth.logic.azure.com/workflows/your-logic-app-url
FLOW_KEY=your-flow-key-value

FLOW_URL=https://prod-15.uksouth.logic.azure.com/workflows/7a854d30969e4158bac2b17ac15d1ad7/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=FrLhWsuldO9AiPgF4ztcjuvjsSrBrJtlD5Mf17jjU_I
FLOW_KEY=ABC123

Demo 5
X-MS-CLIENT-PRINCIPAL-ID
"X-MS-CLIENT-PRINCIPAL-ID": "1ebcd192-5366-48eb-9028-04610ae1704d"
<fetch>
<entity name="techtwed_settlement">
<attribute name="techtwed_name" />
<attribute name="techtwed_settlementid" />
<filter>
<condition attribute="techtwed_name" operator="eq" value="SET-1001-T8B5" />
</filter>
<link-entity name="contact" from="contactid" to="techtwed_customer" alias="contact">
<link-entity name="adx_externalidentity" from="adx_contactid" to="contactid" alias="externalid">
<filter>
<condition attribute="adx_username" operator="eq" value="1ebcd192-5366-48eb-9028-04610ae1704d" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>

Version: 1.0
Date: November 26, 2024
Author: Ian Tweedie
Pattern Type: Integration & Security Pattern
Classification: Enterprise Architecture Pattern
The Flow Proxy Architecture Pattern provides a secure, scalable solution for generating and delivering custom reports through an authenticated web interface. This pattern addresses the challenge of securely exposing Power Platform automated document generation capabilities to end users while maintaining enterprise-grade security controls.
Organizations often require secure access to dynamically generated documents based on database content. Traditional approaches involve complex user interfaces or direct system access, which can be costly and pose security risks.
graph TB
subgraph "Presentation Layer"
A[Web Browser]
end
subgraph "Integration Layer"
B[Azure Function<br/>Flow Proxy]
C[Azure B2C Authentication]
end
subgraph "Business Logic Layer"
D[Power Automate Flow]
E[Word Template Engine]
end
subgraph "Data Layer"
F[Microsoft Dataverse]
G[SharePoint Templates]
end
A --> B
B --> C
C --> B
B --> D
D --> E
D --> F
D --> G
E --> B
B --> A
| Component | Responsibility | Technology |
|---|---|---|
| Flow Proxy | Request routing, header management, authentication integration | Azure Function |
| Authentication Service | User identity verification | Azure B2C |
| Document Generator | Template processing, data merging | Power Automate |
| Template Engine | Word document template processing | Office 365 |
| Data Service | Business data retrieval | Microsoft Dataverse |
| Template Repository | Document template storage | SharePoint |
sequenceDiagram
autonumber
actor User as End User
participant Proxy as Flow Proxy
participant Auth as Azure B2C
participant Flow as Power Automate
participant DV as Dataverse
participant SP as SharePoint
User->>Proxy: HTTP Request with Parameters
Proxy->>Auth: Validate Authentication
Auth-->>Proxy: Authentication Context
Proxy->>Flow: Forwarded Request + Headers
Flow->>DV: Query Business Data
DV-->>Flow: Return Data Records
Flow->>SP: Retrieve Document Template
SP-->>Flow: Return Word Template
Flow->>Flow: Merge Data with Template
Flow-->>Proxy: Generated PDF Document
Proxy-->>User: HTTP Response (PDF)
erDiagram
USER ||--o{ SETTLEMENT : "has access to"
SETTLEMENT ||--|| DOCUMENT : "generates"
USER {
string UserId PK
string Email
string DisplayName
datetime LastLogin
}
SETTLEMENT {
string SettlementId PK
string Name
string Status
datetime CreatedDate
string CustomerId FK
}
DOCUMENT {
string DocumentId PK
string SettlementId FK
string TemplateId
datetime GeneratedDate
blob Content
}
graph TB
subgraph "Microsoft Cloud Platform"
subgraph "Azure"
AF[Azure Functions]
AB2C[Azure B2C]
ASP[App Service Plan]
AI[Application Insights]
end
subgraph "Power Platform"
PA[Power Automate]
DV[Dataverse]
end
subgraph "Microsoft 365"
SP[SharePoint Online]
WORD[Word Online]
end
end
subgraph "Client"
WB[Web Browser]
end
WB --> AF
AF --> AB2C
AF --> PA
PA --> DV
PA --> SP
PA --> WORD
| Layer | Component | Technology | Version | Purpose |
|---|---|---|---|---|
| Client | Web Browser | Any Modern Browser | Current | Document access interface |
| Security | Authentication | Azure B2C | v2.0 | User identity management |
| Integration | Reverse Proxy | Azure Functions | v4.x | Request routing and security |
| Process | Automation Engine | Power Automate | Current | Document generation workflow |
| Template | Document Engine | Word Online | Current | Template processing |
| Data | Database | Microsoft Dataverse | Current | Business data storage |
| Storage | File Storage | SharePoint Online | Current | Template repository |
| Monitoring | Telemetry | Application Insights | Current | Performance monitoring |
graph TB
subgraph "Security Controls"
subgraph "Authentication Layer"
B2C[Azure B2C Identity Provider]
JWT[JWT Token Validation]
end
subgraph "Authorization Layer"
RBAC[Role-Based Access Control]
RowSec[Row-Level Security]
end
subgraph "Transport Layer"
HTTPS[HTTPS/TLS 1.2+]
CORS[CORS Policy]
end
subgraph "Application Layer"
KeyMgmt[Key Management]
HeaderVal[Header Validation]
end
end
| Control Type | Implementation | Technology | Description |
|---|---|---|---|
| Identity | Multi-tenant B2C | Azure B2C | User authentication and profile management |
| Authentication | OpenID Connect | OAuth 2.0/OIDC | Token-based authentication |
| Authorization | Claims-based | FetchXML queries | User-specific data filtering |
| Transport | SSL/TLS | HTTPS | Encrypted communication |
| Application | API Keys | Environment Variables | Service-to-service authentication |
| Data | Row-level filtering | Dataverse Security | User context-based data access |
Decision: Use Azure Functions as the reverse proxy component
Rationale: Native Azure integration, automatic scaling, minimal infrastructure overhead
Alternatives Considered: Azure Application Gateway, NGINX on VM
Status: Approved
Decision: Use Power Automate for business logic and document generation
Rationale: Low-code approach, native Office integration, business user maintainable
Alternatives Considered: Custom .NET application, Logic Apps
Status: Approved
Decision: Implement Azure B2C for user authentication
Rationale: Enterprise-grade identity management, customizable user journeys
Alternatives Considered: Azure AD, custom authentication
Status: Approved
classDiagram
class Client {
+request()
}
class Proxy {
+authenticate()
+forward()
+request()
}
class RealService {
+request()
}
Client --> Proxy
Proxy --> RealService
Proxy : -realService
Implementation: Azure Function acts as a proxy, handling authentication and forwarding requests to Power Automate flows.
Implementation: Word templates define the document structure, while Power Automate fills in dynamic content.
Implementation: Azure Function serves as an API gateway, providing a single entry point for external requests.
graph LR
subgraph "Monitoring Tools"
AI[Application Insights]
PAM[Power Automate Monitoring]
AM[Azure Monitor]
LA[Log Analytics]
end
subgraph "Alerting"
EMAIL[Email Alerts]
TEAMS[Teams Notifications]
SMS[SMS Alerts]
end
AI --> EMAIL
PAM --> TEAMS
AM --> SMS
| Risk | Likelihood | Impact | Mitigation Strategy |
|---|---|---|---|
| Service Dependencies | Medium | High | Implement circuit breaker patterns, fallback mechanisms |
| Authentication Failure | Low | High | Multiple authentication providers, manual override procedures |
| Performance Degradation | Medium | Medium | Auto-scaling, performance monitoring, capacity planning |
| Data Breach | Low | High | End-to-end encryption, access controls, audit logging |
| Risk | Likelihood | Impact | Mitigation Strategy |
|---|---|---|---|
| User Adoption | Medium | Medium | User training, change management, feedback collection |
| Compliance Issues | Low | High | Regular compliance audits, legal review, documentation |
| Cost Overruns | Medium | Low | Cost monitoring, usage alerts, budget controls |
The Flow Proxy Architecture Pattern provides a robust, secure, and scalable solution for authenticated document generation and delivery. By leveraging cloud-native services and modern authentication patterns, this architecture delivers significant business value while maintaining enterprise-grade security and compliance requirements.
{
"FLOW_URL": "https://prod-xx.uksouth.logic.azure.com/workflows/{workflow-id}/triggers/manual/paths/invoke",
"FLOW_KEY": "your-flow-key-value",
"CORS_ORIGINS": "*",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
<!-- FetchXML Example -->
<fetch>
<entity name="settlement">
<attribute name="name" />
<attribute name="settlementid" />
<filter>
<condition attribute="name" operator="eq" value="@{triggerOutputs()['queries']['row']}" />
</filter>
<link-entity name="contact" from="contactid" to="customer">
<link-entity name="externalidentity" from="contactid" to="contactid">
<filter>
<condition attribute="username" operator="eq" value="@{triggerOutputs()['headers']['X-MS-CLIENT-PRINCIPAL-ID']}" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>
Available at: GitHub Repository
Document Control
Version History:
Review Cycle: Annual
Next Review Date: November 26, 2025
Approved By: Enterprise Architecture Review Board