Exercise - Add an approval stage to a pipeline
In this exercise, you create an approval cloud flow that a pipeline deployment triggers.
Scenario
You manage Microsoft Power Platform pipelines. You need to add an approval gate before you process deployments to the user acceptance testing (UAT) environment. You need to send this approval to a specific user at your organization.
Exercise steps
The following exercise takes you through the steps of extending a pipeline by using a Power Automate cloud flow that contains an approval action.
Preparation
Create Microsoft Power Platform source and target environments or identify those that you have permission to create, modify, and run pipelines in and can use for this exercise. Ensure that the Deployment Pipeline configuration application is installed.
For detailed steps on installing the configuration application, see Configure pipelines using a custom host - Microsoft Power Platform | Microsoft Learn.
Create a pipeline to deploy solutions from the source environment to the target environment in the configuration application. Turn on the Pre-Deployment Step Required option for the initial stage of this pipeline. The following video demonstrates the steps in this exercise.
Exercise
In Power Automate Studio, select the source environment and then create an automated cloud flow.
Then, follow these steps:
Add a When an action is performed Dataverse trigger.
Configure the Catalog parameter as Microsoft Dataverse Common.
Configure the Category parameter as Power Platform Pipelines.
Configure the Table Name parameter as (none).
Configure the Action Name parameter as OnPreDeploymentStarted.
On the Settings tab, enter a Trigger Condition parameter as follows:
@equals(triggerOutputs()?['body/OutputParameters/DeploymentPipelineName'], 'The name of the pipeline to extend')
Add a Start and wait for an approval action.
Configure the Approval Type parameter as Approve/Reject – First to respond.
Enter a meaningful title for the Title parameter, such as:
Please review the Deployment request for @{triggerOutputs()?['body/OutputParameters/DeploymentPipelineName']}
.Enter the email address of the approver for the Assigned To parameter.
You can also configure other optional parameters to provide more details in the approval message
Add a Condition action.
Evaluate the value for
first(item()?['approverResponse'])
.Compare the value from the previous step to
Approve
.When you use the
first()
formula, the system automatically adds a For each loop and the True and False branches to the flow.Add a Perform an unbound action Dataverse action in the True branch.
In the Action Name parameter, select UpdatePreDeploymentStepStatus.
In the Item/PreDeploymentStepStatus advanced parameter, enter the success value of 20.
Optionally, provide a comment, such as the approver's comment for the Item/Comments advanced parameter.
Configure the Item/StageRunId advanced parameter with a
StageRunId
value from the trigger.Repeat steps 14 to 18 for the False branch and with a Fail value of 30 at step 16.
To complete the exercise, save the cloud flow and then launch a new deployment of the pipeline that you extended with this flow. You can test the approving and declining actions to confirm whether the deployment continues or stops based on that decision.
Next steps
Now you learned how to extend a pipeline by using a Power Automate cloud flow that launches an approval process to stop or continue a deployment. Next, you have the opportunity to validate the learned concepts for this module.