for Trailmark Fund Solutions

Power Automate Flows

An implementation plan for the build team: the nightly reporting automation expressed as concrete Power Automate flows — each flow's steps as a diagram, the exact actions and connectors it uses, and how it authenticates. Technical claims verified against Microsoft Learn (2026-08-28).

How each flow authenticates

Power Automate and Azure resources authenticate differently, and the two are easy to conflate — so this comes first.

Power Automate cloud flows — service account, not Managed Identity
Power Automate cloud flows do not have a Managed Identity (that is an Azure-resource feature). Their connections — Azure Blob, SharePoint, Outlook, Approvals — run under a dedicated service account using Microsoft Entra ID Integrated (token-based, no access key), or a service principal. There is no stored storage-account key, but there is a stored delegated connection tied to that service account.
Azure resources — Managed Identity
The two pieces that run as Azure resources use passwordless Managed Identity: the Azure Function that builds and sends the email (application permissions Mail.ReadWrite + Mail.Send, scoped to reporting@trailmark.us via RBAC for Applications in Exchange Online), and the Automation Account that opens and closes the SFTP window (scoped to the one storage account).
One delegated exception — the workbook refresh
Office Scripts (Excel Online Business "Run script") only runs signed in as an actual account, because the Excel Graph Workbook API does not support app-only access. So the refresh step runs under a dedicated delegated service account — the one place that keeps a stored sign-in.

Flow 1 — File intake & organization

Steps 1–2. Trigger: a file lands in Azure Blob from the SFTP delivery. Outcome: the original sits in RAW data; a renamed copy sits in Working / {client}.

Blob triggeradded or modified (properties only)
Get blob contentthe new file
RAW data librarysave original, untouched
Resolve client + renameClients list → convention
Working / {client}renamed copy
Action set
StepAction / connectorNotes
TriggerAzure Blob — When a blob is added or modified (properties only)Root folder only; ignores pre-existing blobs (one-time cutover backfill)
Get fileAzure Blob — Get blob contentBy path from the trigger
Keep originalSharePoint — Create fileRAW data library, original name + format
Resolve clientSharePoint — Get itemsClients list, match by identifier prefix → target folder
Rename & sortSharePoint — Create fileWorking / {client}, renamed to the standard convention
LogSharePoint — Create itemRun Log: arrived / sorted

Auth: dedicated service account (Microsoft Entra ID Integrated) for Blob and SharePoint — not Managed Identity.

Flow 2 — Workbook refresh & report generation

Steps 3–4. The night's data refreshes the reporting workbook using the real Excel engine, the fund's NAV is captured to a dated list, and the clean client report is produced.

Triggerfiles ready in Working
Run scriptOffice Scripts — refresh + recalc
NAV Valuesappend dated row
Generate reportclean PDF + Excel
Working / {client}finished report
Action set
StepAction / connectorNotes
Refresh workbookExcel Online (Business) — Run scriptOffice Scripts drives the real Excel engine. Limits: 120s sync timeout, 5MB/request, 28.6MB parameter, 1,600 runs/user/day
Capture NAVSharePoint — Create itemNAV Values: new dated row (Fund, As-of date, Share price)
Produce reportGraph — content conversion (?format=pdf) / Office Script exportInternal columns removed; clean PDF + Excel
Save reportSharePoint — Create fileWorking / {client}
LogSharePoint — Create itemRun Log: generated

Auth: the Run script step runs under a dedicated delegated service account (the one credentialed step); everything else via the service-account connections.

Flow 3 — Email: draft, approve, send, archive

Steps 5–7. The system builds the full email as a draft, holds it for approval (or sends automatically), sends on approval, then archives the night's files and writes the run log.

Get config3 SharePoint lists
Build draftFunction — Graph Create message + attach
Send Mode?condition
SendGraph send by id
Archive + Run LogWorking → Archive
The branch on Send Mode
Manual (default): "Start and wait for an approval" goes to the approver with a preview (subject, recipients, body snippet) and a link to the draft (editable in Outlook Online). Approve → Graph sends the draft by id, so the approver's edits carry through. Reject → delete the draft, log, stop. Automatic: the flow sends immediately, no approval.
Action set
StepAction / connectorNotes
Get configSharePoint — Get itemsNotification Assignments, Email Sender Settings, NAV Values
Build draft + attachAzure Function (Graph SDK)Create message in reporting@trailmark.us + attach report; ≤3MB single POST, 3–150MB upload session (LargeFileUploadTask); returns id + webLink
BranchConditionSend Mode: Manual / Automatic
Approval (Manual)Approvals — Start and wait for an approvalPreview + link to the draft; Approve / Reject
SendMicrosoft GraphPOST /users/reporting@trailmark.us/messages/{id}/send
Reject cleanupMicrosoft GraphDelete the draft message
ArchiveSharePoint — Move / Copy fileWorking / {client} → Archive / {year} / {date}
Run LogSharePoint — Create itemapproved/sent, success/failure, detailed log

Auth: the draft build + send run in the Azure Function on Managed Identity (Mail.ReadWrite + Mail.Send, App RBAC-scoped to the one mailbox); orchestration, approval and Run Log run in Power Automate under the service account.

Supporting automations (not cloud flows)

Two pieces run as Azure resources rather than Power Automate cloud flows — documented here so the whole picture sits in one place.

Azure Function — email draft & large attachments
.NET + Graph SDK. Builds the draft in the shared mailbox and uploads attachments, using LargeFileUploadTask for files over 3MB (raw Power Automate cannot do chunked byte-range uploads reliably). Managed Identity + Mail.ReadWrite + Mail.Send, scoped to reporting@trailmark.us via App RBAC. Called by Flow 3.
Azure Automation Account — SFTP window
A PowerShell runbook (Set-AzStorageAccount -EnableSftp) on two schedules: enable the SFTP endpoint before the nightly delivery window, disable it after — because SFTP is billed per enabled hour. Managed Identity scoped to the storage account. Effectively $0/month (inside Azure Automation's 500 free job-minutes).

Every flow also appends to the Run Log SharePoint list (one row per client per run: arrived / generated / approved-or-sent / success-or-failure + detailed log), which the status views and dashboard read from.