Configure Pre-Deployment Stage Approvals

Configure Pre-Deployment Stage Approvals

Power Platform pipelines can be enhanced to include deployment stage approvals. Although there are no-built-in pipeline approvals it is possible to create one using a custom Dataverse table and a Power Automate flow. Stage approvals are important because they help the environment owner control what gets deployed into their environment. An approvals process should be a part of any Power Platform Pipelines process.


Table Of Contents:
• Create A Deployment Stage Approver TableAdd Entra ID User & Deployment Stage Lookup ColumnsSetup The Deployment Stage Approver Main FormConfigure The Test Deployment Stage ApproverAssign The Production Deployment Stage ApproverCreate A Power Platform Pipelines Approval Cloud FlowGet The Deployment Stage ApproversObtain The Approvers User Principal NameSend An Deployment Stage Approval To TeamsApprove Or Reject The The Request For DeploymentDeploy The Solution To The Test Deployment StageComplete Pipeline Approvals Power Automate Flow Screenshot




Create A Deployment Stage Approver Table

We want to allow a Power Platform pipelines administrator to add approvers to a deployment stage. To do this we will create a new Dataverse table. Go to the Pipelines Host environment and open the solutions menu.



Inside of a solution, add a new Dataverse table.



Name the table Deployment Stage Approver and press the Save button.



Power Apps will redirect us to the Deployment Stage Approver table landing page.




Add Entra ID User & Deployment Stage Lookup Columns

A Power Platform pipelines administrator will configure approvals by adding a user and a deployment stage as a new record in the Deployment Stage Approvers table. Go to the columns page and select New column.



Name the column Entra ID user and select the data type Lookup. Make the field required. And choose the Microsoft Entra ID table. Then press the Save button.



Create a second column named Deployment Stage as a Lookup data type. Make it a required field and set the related table to Deployment Stage. Press the Save button once finished.




Setup The Deployment Stage Approver Main Form

We want the Power Platform pipelines approval to be configurable within the Deployment Pipelines Configuration app. Therefore we will need to setup a the table’s main form. Switch to the Deployment Stage Approver table’s Forms page and open the main form.



Add the Deployment Stage field and the Entra ID User field to the form. Save and publish the form then exit.




Configure The Test Deployment Stage Approver

We are now ready to configure the approver for a Power Platform pipelines deployment stage. Open the Deployment Pipeline Configuration app and browse to the Pipelines page. Select the test deployment stage record.



On the deployment stage form, check the pre-deployment step required checkbox.



Then go to the related tab and select Deployment Stage Approvers.



Press the New Deployment Stage Approvers button.



Fill-in the Deployment Stage Approver form with the Test Deployment Stage and the Entra ID User who will be the approver.




Assign The Production Deployment Stage Approver

The deployment to the production stage will also require an approver. Select the production deployment stage record.



Then on the main form check the pre-deployment stage required checkbox.



Next, open the related tab and choose Deployment Stage Approvers from the dropdown menu.



Press the New Deployment Stage Approver button.



Assign the approver to the Entra ID User field and select the production deployment stage.




Create A Power Platform Pipelines Approval Cloud Flow

We will use Power Automate approvals to provide an interface for stage owners to approve and reject deployments. In the solution, create a new automated cloud flow with the name Approve Pipelines Deployment. Select the Dataverse trigger when an action is performed.



Set the flow trigger category to Power Platform Pipelines and use the action name OnApprovalStarted




Get The Deployment Stage Approvers

After the cloud flow is triggered we want to get the list of deployment stage approvers so we can send them an approval request. Determining the approvers requires multiple flow actions.

Start by adding a Dataverse – Get A Row By ID Action and target the Deployment Stage Runs table. Use the StageRunId from the trigger as the Row ID. Then insert another Dataverse – Get A Row By ID action with the Deployment Stages table. Supply the deployment stage id from the previous action in the Row ID field.



There could be multiple deployment stage approvers so the next step requires a Dataverse – List Rows action.



Write this code in the Filter Rows field to get all approvers with a matching deployment stage.

_new_deploymentstage_value eq @{outputs('Get_a_row_by_ID:_Deployment_Stage')?['body/deploymentstageid']}




Obtain The Approvers User Principal Name

Now we have an array of deployment stage approvers. But what we really need is a semi-colon separated list of user principal names (emails) to use in an Approvals flow action.

Initialize a string variable named varStageApprovers. Then for each deployment stage approver,use the Office 365 Users – Get User Profile (V2) action and supply the Entra User ID to retrieve the user principal name. Append each user principal name to the string variable with a semi-colon at the end.




Send An Deployment Stage Approval To Teams

We have everything we need to send an approval request to the deployment stage approvers. Add an Approvals – Start and wait for an approval action with the following values:

  • Approval type – Approve/Reject – First to respond
  • Title: Deployment Approval Request
  • Assigned to: varStageApprovers
  • Details: Please approve deployment of the <Artifact Name> solution to the <Deployment Stage Name> stage.




Approve Or Reject The The Request For Deployment

After the approvals action, insert a condition action to check the outcome of the approval. If yes, perform an unbound action to approve deployment. Fill-in the action with the following values:

  • Action Name – UpdateApprovalStatus
  • Approval Properties – workflow()
  • StageRunId – Action Inputs StageRunId
  • Approval Status – 20 (approved)

In the no condition perform the same unbound action with an Approval Status of 30 (rejected).




Deploy The Solution To The Test Deployment Stage

All that is left now is to run the pipeline make the sure the approvals we setup are working. Navigate to the sample solution in the development environment and open the pipelines menu. Press the deploy here button on the test stage.



Behind the scenes the Power Automate flow is triggered and sends an approval request to the deployment stage approver.



Once the approver presses the Approve button the pipeline continues with deployment.




Complete Pipeline Approvals Power Automate Flow Screenshot

Here is a screenshot of the full Power Automate flow to approve deployments with Power Platform Pipelines.




Next Steps

Continue to the next steps in the Power Platform Pipelines & ALM Setup Guide.

Next: Setup Dataverse Git Integration For A Solution >>





Questions?

If you have any questions about Configure Pre-Deployment Stage Approvals please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Subscribe
Notify of
guest

3 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Modest
Modest
8 days ago

Great

Moses Babalola
Moses Babalola
7 days ago

Is the cloud flow trigger OnApprovalStarted or OnPreDeploymentStarted ?