Posted on 4 Comments

Pass parameters from Power automate to Azure DevOps pipeline using rest api

Recently I had to implement the scenario that is depicted below.

In more detail I had to implement a way to get user input (usernames) in order to pass this information on an Azure DevOps pipeline and through this pipeline make some actions on Azure through az cli.

For the described solution I used the below services:

  • Azure Devops
  • Power Automate
  • Azure DevOps rest API
  • Azure

The first thing that I created was the form. In this form the user has to provide the input of the usernames in a requested format in order to pass this information on the later components.

Then I created a new power automate flow that would handle the input of this form and make a POST request on Azure DevOps api in order to trigger a build pipeline with the parameters of the form as input.

The flow and the task that have been used are depicted below.

Select response ID on the form.

On the POST request you should enter your details regarding the pipeline ID, organization and project. The body of the request should be as shown in order to get the parameters parsed correctly.

The azure devops pipeline will have as an input parameter and empty object.

trigger: none
pr: none 
pool:
  vmImage: windows-latest

parameters:
  - name: users
    type: object
    default: []

jobs:
  - job: vdi
    displayName: rest api pipeline
    steps:
      
    - ${{ each user in parameters.users }}:
      - task: PowerShell@2
        inputs:
          targetType: 'inline'
          script: |        
            Write-Host "${{user}}"
          

When user submits the form

then the power app will run

and as a result the azure devops pipeline will be triggered through the rest api.

Finally the pipeline will parse the parameters provided by the form.

Posted on Leave a comment

Connect to power platform – Azure Devops pipelines

In this article I will explain how to create a Power platform environment and connect on it through Azure Devops pipelines. Power platform is a low code environment provided by Microsoft that can implement services and functionality quickly with a GUI.

In order to follow the tutorial you will need an Azure subscription and a power platform subscription which will be connected.

First things first, you should create a power platform environment. You can do this, by logging in the Power Platform admin center and pressing the New button.

Then you should select the type and region and also the database connection. I chose a sample database so that I get automatically data to test.

By choosing the trial subscription the environment only works for 30 days. This is good enough for the purposes of this article but not for production environments. After the provision of the environment you will get the environment URL and also some sessions details that will be needed for Azure devops.

You can find the sessions details on the right upper corner.

The you will need to create an app registration on your Azure subscription.

Press New registration

Give a name and select which accounts could access this application.

After the provision of the application, you will have to set the API permissions. Select Dynamics CRM -> User impersonation

Then you will have to create a secret for the application. Go to certificates and secrets and create a new client secret. Copy the value, as it will be needed later.

On Azure Devops you should create a service connection. Go to project settings -> Service connections and add a new connection. Select power platform on the connection type.

You should then add the connection details gathered on previous steps. Client secret and application ID from the Azure application that you created. The server URL and tenant ID can be gathered from power platform admin center.

Then go and create a new Pipeline on Azure Devops and add the below two steps. The power platform tools installer is required any time you want to connect on power platform. This will instruct the build agent to download the necessary tools for the deployment. The WhoAmI task will authenticate with the instance and verify if the connection is working.

Edit the WhoAmI step and include the service connection

Check the result of the task, as it should be successful (Green)