Add Approval Gates Before Pipeline Deployments
Implement pre-deployment approval checks in Power Platform Pipelines using a custom Dataverse table and Power Automate approvals.
Power Platform Pipelines provide a streamlined path to move solutions between environments, but they lack a built‑in approval mechanism. Without an approval gate, any authorized user can deploy to a production stage without oversight. By combining a custom Dataverse table with a Power Automate approval flow, you can enforce that one or more designated approvers must sign off before a deployment proceeds. This article walks through a practical implementation that you can adapt to your own ALM governance requirements.
Understanding the Approval Flow
The pipeline triggers a Power Automate flow when a pre‑deployment action is initiated. That flow looks up the approvers configured for the target stage, sends them an approval request (via Teams, email, or the Approvals center), and then updates the pipeline's status based on the response. The entire process runs inside the Pipelines Host environment, keeping everything centralized.
Our example uses these fictional entities:
- Stage Gate Approver – a custom table that links an Entra ID user to a specific deployment stage.
- Gate Review Flow – the Power Automate flow that orchestrates approval.
- Environment stages –
Review(validation) andRelease(production), each requiring separate approvals.
Creating the Stage Gate Approver Table
Open the solution editor in your Pipelines Host environment. Create a new table named Stage Gate Approver and set ownership to User or Team. After saving, add two required lookup columns:
| Column name | Lookup to |
|---|---|
Gate Approver | Microsoft Entra ID User |
Target Stage | Deployment Stage |
These columns define who can approve and which stage they oversee. You can also add optional fields like Approver Priority or Is Active to support multiple approvers or to temporarily disable a gate.
Adding the Form to the Pipelines Configuration App
- Open the Main Form for the Stage Gate Approver table.
- Add both lookup fields (
Gate Approver,Target Stage) to the form. - Save and publish the form.
Now administrators can configure approvers directly from the Deployment Pipeline Configuration app without leaving the Pipelines interface.
Assigning Approvers to Pipeline Stages
- Launch the Deployment Pipeline Configuration app and go to Pipelines.
- Select the deployment stage you want to protect (e.g.,
Review Stage). - In the stage form, mark Pre‑deployment step required as Yes. This tells the pipeline engine to trigger the approval flow before the actual deployment.
- Navigate to the Related tab and choose Stage Gate Approvers.
- Click New Stage Gate Approver and fill in the lookup fields:
- Target Stage – the stage you are configuring.
- Gate Approver – the Entra ID user that must approve.
- Save the record.
Repeat the process for every stage that needs an approval gate (e.g., Release Stage). You can assign multiple approvers per stage; the flow will send the approval request to all of them and act on the first response.
Building the Approval Automation
In the same solution, create an Automated cloud flow triggered by the Dataverse action When an action is performed. Configure the trigger:
| Parameter | Value |
|---|---|
| Trigger category | Power Platform Pipelines |
| Action name | OnApprovalStarted |
The flow receives a StageRunId that identifies the pipeline run.
Retrieving the Stage and Its Approvers
- Get a row by ID using the
Deployment Stage Runstable and theStageRunId. Store theDeployment StageID from the result. - Get a row by ID on the
Deployment Stagestable using the stage ID. This gives you the stage details. - List rows on the
Stage Gate Approvertable with a filter that returns only rows matching the current stage:
_new_tg_stage_value eq @{outputs('Get_a_row_by_ID:_Deployment_Stage')?['body/deploymentstageid']}The exact filter expression depends on the schema name you chose; the pattern above uses the temporary name _new_tg_stage_value. After adding the flow step, use the Peek code feature to find the correct schema name for your lookup column.
Building the Approvers Email List
A Start and wait for an approval action expects a semicolon‑separated list of email addresses (User Principal Names). Because we have a collection of approver rows, we need to compose that string:
- Initialize a string variable named
varApproverEmailswith an empty value. - Apply to each the approver rows from the list step.
- Inside the loop, use Get user profile (V2) from the Office 365 Users connector with the approver’s Entra ID.
- Append to string variable using the expression:
concat(variables('varApproverEmails'),
outputs('Get_user_profile')?['body/mail'],
';')This builds a string like alice@contoso.com;bob@contoso.com;.
Sending the Approval Request
Add an Approvals – Start and wait for an approval action:
| Field | Value |
|---|---|
| Approval type | Approve/Reject – First to respond |
| Title | Deployment approval required: {Artifact Name} to {Stage Name} |
| Assigned to | varApproverEmails |
| Details | Please approve or reject the deployment of {Artifact Name} to the {Stage Name} stage. |
You can pull {Artifact Name} and {Stage Name} from the earlier Dataverse lookups using dynamic content.
Marking the Pipeline as Approved or Rejected
After the approval action, add a Condition that checks the outcome of the approval.
-
If the outcome equals
Approve→ use the unbound Dataverse action UpdateApprovalStatus with these inputs:- Approval Properties:
workflow()(the trigger outputs) - StageRunId: the
StageRunIdfrom the trigger - Approval Status:
20(approved)
- Approval Properties:
-
Else (rejected or canceled) → same UpdateApprovalStatus action but with Approval Status:
30(rejected)
Approval Status: 20
StageRunId: @{triggerOutputs()?['body/StageRunId']}The pipeline engine listens for this status change and continues or stops the deployment accordingly.
Testing the Implementation
- In a development environment that is connected to your pipeline, open a solution and select Deploy.
- Choose the target stage that has approvals enabled.
- The pipeline will show a “pending approval” state as soon as the flow triggers.
- The approver receives the request in Teams, email, or the Power Automate Approvals center.
- After approval, the pipeline proceeds to deploy. If rejected, the run is marked as failed and the solution is not applied.
Security and Delegation Considerations
- The flow must run under an identity that has write privileges to the
Deployment Stage Runstable and can execute theUpdateApprovalStatusaction. Usually the System Customizer or Pipeline Admin role suffices. - Approver users need no additional permissions beyond being able to see the approval request.
- The Stage Gate Approver table is stored in the Pipelines Host environment. Ensure the flow’s Dataverse connection points to that environment.
- For sensitive stages, consider using a separate approval flow per stage to limit the blast radius of a misconfiguration.
Common Mistakes and Troubleshooting
| Issue | Likely cause | Solution |
|---|---|---|
| Flow not triggered | Pre‑deployment required flag not set on the stage | Mark the stage as requiring pre‑deployment step |
| Filter returns no rows | Wrong column schema name or incorrect GUID comparison | Peek code of the stage ID output and update the field name |
| Approval request not delivered | varApproverEmails is empty or contains invalid UPNs | Check each user profile lookup output; test with a single user |
| UpdateApprovalStatus fails | Flow owner lacks permissions on DeploymentStageRun entity | Grant Pipeline Administrator role to the flow owner |
| Deployment hangs after approval | The approval status update did not execute; missing workflow() | Ensure Approval Properties is set to workflow() |
A Final Recommendation
Adding approval gates to Power Platform Pipelines significantly strengthens your ALM security without requiring expensive third‑party tools. The pattern described here is maintainable and can be extended to include multi‑stage approvals, escalation timers, or integration with Microsoft Teams adaptive cards. Start with a single critical stage, validate the flow with a test user, and then roll it out to your entire pipeline.
References
- Original source: Configure Pre‑Deployment Stage Approvals by Matthew Devaney
- Microsoft Learn: Set up Power Platform Pipelines (placeholder, verify exact URL)
- Microsoft Learn: Use Power Automate approvals (placeholder, verify exact URL)