Azure DevOps PR Created to Approval Flow
When a pull request is created, trigger a Power Automate approval; on approve, add a comment to the PR with the approval details.
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 monitors an Azure DevOps Git repository for new pull requests and automatically triggers a Power Automate approval. When a PR is created, the designated approver receives an approval request with full PR details (title, author, branches, description). Upon approval, an "Approved" comment thread is posted directly to the PR in Azure DevOps and a confirmation email is sent. If rejected, a "Rejected" comment thread is posted instead with the rejection reason.
Use Case
Development teams need a lightweight approval gate for pull requests that integrates with their existing Power Automate and Microsoft 365 workflows. This flow adds a business approval step on top of Azure DevOps code reviews, ensuring that PRs require explicit sign-off before being merged. The approval status is documented directly on the PR as a comment thread for full traceability.
The flow is ideal for teams that:
- Automated approval requests sent instantly when PRs are created
- Full PR context (title, author, branches, description) included in the approval
- Approval/rejection comments posted directly to the PR thread in Azure DevOps
- Email notifications for both outcomes
- Fully configurable via environment variables — portable to any tenant
Flow Architecture
When a Pull Request Is Created
OpenApiConnection (polling)Polls Azure DevOps every 5 minutes for new PRs in the configured repo.
Initialize varApproverEmail
InitializeVariableReads the flowlibs_PRApproverEmail environment variable.
Initialize varNotificationEmail
InitializeVariableReads the flowlibs_NotificationEmailAddress environment variable.
Initialize varOrgName
InitializeVariableReads the flowlibs_AzureDevOpsOrgName environment variable.
Initialize varProject
InitializeVariableReads the flowlibs_AzureDevOpsProject environment variable.
Initialize varRepoId
InitializeVariableReads the flowlibs_AzureDevOpsRepoId environment variable.
Compose PR Summary
ComposeBuilds an HTML summary with PR title, author, source/target branches, repo, and description for use in the approval request.
Start And Wait For PR Approval
OpenApiConnectionWebhookCreates a Basic approval assigned to the configured approver and waits for a response.
Check If Approved
If conditionChecks whether the approval outcome equals "Approve".
- — Builds the JSON body for an "Approved" PR thread comment.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_AzureDevOpsOrgName | String | MyOrg | The Azure DevOps organization name (from dev.azure.com/<org>). |
| flowlibs_AzureDevOpsProject | String | MyProject | The project to monitor for pull requests. |
| flowlibs_AzureDevOpsRepoId | String | MyRepo | The Git repository name or GUID to watch for new PRs. |
| flowlibs_PRApproverEmail | String | you@yourcompany.com | Who receives the approval request. |
| flowlibs_NotificationEmailAddress | String | you@yourcompany.com | Who receives the outcome notification emails. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| Azure DevOps | shared_visualstudioteamservices | OnGitPullCreated (trigger) HttpRequest (posts PR comment threads) |
| Approvals | shared_approvals | StartAndWaitForAnApproval (creates and waits for the PR approval) |
| Office 365 Outlook | shared_office365 | SendEmailV2 (sends approval/rejection notification emails) |
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.
- Change polling frequency
- Edit the trigger interval (default: 5 minutes). Shorter intervals detect PRs faster but consume more API calls.
- Filter by target branch
- Add the targetRefName parameter to the trigger to only fire for PRs targeting refs/heads/main (or another branch).
- Add multiple approvers
- Change the approval type from "Basic" to "Everyone must approve" and set multiple emails semicolon-separated in flowlibs_PRApproverEmail.
- Add Teams notification
- Add a Post Message to Teams action alongside the email inside the If branches for dual-channel alerts.
- Auto-complete the PR on approval
- Add an additional Azure DevOps HttpRequest action after the approval comment to PATCH the PR status to "completed".
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.01Get PR title from trigger
Pulls the pull request title from the trigger output.
EXPR.02Get PR author name
Display name of the PR author.
EXPR.03Get source branch
Source branch reference (e.g., refs/heads/feature-x).
EXPR.04Get target branch
Target branch reference (e.g., refs/heads/main).
EXPR.05Get PR ID
Numeric pull request ID used when building the REST API URL.
EXPR.06Get repo name
Repository name from the trigger output.
EXPR.07Null-safe description
Falls back to a placeholder when the PR description is empty.
EXPR.08Check approval outcome
Compared against the string 'Approve' in the If condition.
EXPR.09Get approver display name
Display name of the first responder on the approval.
EXPR.10Get approver comments
Null-safe access to the approver's free-text comments.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.