PagerDuty Maintenance Window Scheduler
Reads scheduled maintenance/change windows from a Dataverse change calendar and creates matching PagerDuty maintenance windows to suppress alerts on the affected services for the duration, then removes them after. Posts confirmations to Teams and warns if a window overlaps a change freeze. Prevents noisy false pages during planned work.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This flow keeps PagerDuty alerting quiet during planned work by syncing a Dataverse change calendar into PagerDuty maintenance windows. On an hourly schedule it reads approved change windows due to start soon, creates a matching PagerDuty maintenance window over the affected services (suppressing alerts for the duration), and posts a confirmation to Microsoft Teams. Windows that overlap an organisational change freeze are flagged for manual review instead of being auto-suppressed. Rows flagged for early cancellation have their PagerDuty window removed, and windows whose end time has passed are reconciled back to Completed.
Why it matters: Planned maintenance generates alerts that page on-call for nothing. Automatically suppressing the right services for the exact window keeps responders focused on real incidents and gives change managers a governed, auditable record of every suppression. Ships Off (demo); going live requires only connection authorization and environment-variable configuration.
Use Case
An operations team books maintenance in a Dataverse change calendar and wants PagerDuty alerting suppressed on the affected services automatically for each window - no manual maintenance-window creation, and no accidental suppression during a change freeze.
Flow Architecture
Recurrence
Recurrence (Hourly)Look-ahead poll for upcoming and expiring windows.
Initialize variables (1-7)
Initialize VariableLoad LookAheadHours, ServiceMap, FreezeStart, FreezeEnd, TeamsGroupId, TeamsChannelId, PagerDutyBase from env vars.
Query Upcoming Windows
Dataverse ListRecordsApproved windows with no PagerDuty id.
Apply To Each Window
ForeachFor each candidate: if due within the horizon and not in a change freeze, resolve services and create the window.
Create Maintenance Window
HTTP POST /maintenance_windowsSuppress alerts on affected services; store the PagerDuty id and mark Scheduled.
Warn / Confirm Teams
Teams PostMessageToConversationFlag freeze conflicts (mark Blocked - Freeze) or post a scheduling confirmation.
Query Cancel Requests
Dataverse ListRecordsRows flagged Cancel Requested with a live PagerDuty id.
Apply To Each Cancel
ForeachDELETE /maintenance_windows/{id} ahead of schedule, mark Cancelled, and notify Teams.
Query Expired Windows
Dataverse ListRecordsScheduled rows whose end time has passed.
Apply To Each Expired
ForeachMark each Completed (PagerDuty auto-ends at end_time).
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_PagerDutyApiBase | String | https://api.pagerduty.com | PagerDuty REST base URL (reused). |
| flowlibs_PagerDutyApiToken | String | REPLACE_WITH_PAGERDUTY_API_TOKEN | PagerDuty REST API token (Token-header auth). |
| flowlibs_PagerDutyFromEmail | String | alerts@yourcompany.com | From header email (a valid PD user) - required for write ops. |
| flowlibs_ChangeCalendarTable | String | flowlibs_changewindows | Entity set name read by ListRecords. |
| flowlibs_ServiceMap | String | {"billing-prod":["PSVC001"],"web-prod":["PSVC002","PSVC003"],"db-prod":["PSVC004"]} | JSON map: System Key -> array of PagerDuty service ids. |
| flowlibs_LookAheadHours | String | 2 | Create windows starting within this many hours. |
| flowlibs_ChangeFreezeStart | String | 2026-12-19T00:00:00Z | Change-freeze start (ISO 8601 UTC). |
| flowlibs_ChangeFreezeEnd | String | 2027-01-05T00:00:00Z | Change-freeze end (ISO 8601 UTC). |
| flowlibs_TeamsGroupId | String | <your-team-id> |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| PagerDuty | shared_pagerduty | POST /maintenance_windows DELETE /maintenance_windows/{id} |
| Microsoft Dataverse | shared_commondataserviceforapps | ListRecords UpdateRecord |
| Microsoft Teams | shared_teams | PostMessageToConversation |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Service Map
- Edit flowlibs_ServiceMap so each change-calendar System Key maps to the PagerDuty service ids it should suppress, e.g. {"billing-prod":["P123ABC"]}.
- Change freeze
- Set flowlibs_ChangeFreezeStart / End to your organisation's freeze period; overlapping windows are flagged in Teams instead of suppressed.
- Look-ahead
- Tune flowlibs_LookAheadHours (how far ahead of start the window is created).
- Early cancel
- Set a row's Status to Cancel Requested to have the flow DELETE its PagerDuty window before the scheduled end.
- Different source
- Swap the Dataverse ListRecords for a ServiceNow / Freshservice change-table read.
- Auto-extend
- Extend a window if the linked change is still in progress at its end time.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Window due
Start falls within the look-ahead horizon.
EXPR.02Freeze overlap
Window overlaps the change-freeze period.
EXPR.03Service resolution
Map System Key to service ids, then Select to service_reference objects.
EXPR.04PagerDuty window id
Stored back on the change row.
EXPR.05Expired filter
Find Scheduled rows past their end time.
Customize & download
Generate a ready-to-import copy of this solution with your environment-variable values baked in — available on Base, Pro, or Team.
Upgrade to customize
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.