Azure Devops

How to create a new project in devops from Power Automate

Today, I have come across a task of creating new project in Azure devops but it should be done through actions using Power Automate (a.k.a flows).After spending ample amount of time to do research and experiments we finally got a solution to create the whole new project in devops.

“Arriving at the solution or not, after failing for 100 times enriches one’s knowledge than quitting at the early stage”

  • First, we need to create a new flow in the power automate : In the left panel go to—> my flows—>new flow—>select any of the below(automated flow, instant flow, scheduled flow, desktop flow).
  • Using flows, we need to define triggers and actions for the sample purpose i choose manual trigger as shown below
Manually trigger a flow
  • Now, to connect to devops, we need to use connectors in which some are free and some are premium but to connect to devops we will use “HTTP” connector which is a premium service btw
  • Select HTTP connector then it will appear as below:
Getting process data from devops organization
  • In the above, we are retrieving various processes data from the devops organization which we are going to use in creation of new project using “GET” method.
  • Below is the link to have a detailed info to use get method in devops:
  • https://docs.microsoft.com/en-us/rest/api/azure/devops/core/projects/get?view=azure-devops-rest-5.1
  • Authentication is necessary by using basic authorization option here we need to provide User name of the organisation and in the password field we need to use PAT(Personal Access Tokens).
  • To create these Personal access tokens , jump to azure devops on the top right of the ribbon one can find profile area there we can find PAT.
  • To have full access of devops create a personal access token and store it securely as once created it won’t be displayed and the expiry of these token are 30 days.
  • Using those PAT in the password field of basic authentication for sending http request to devops this ensures successful creation of connection and using the GET function and URI we can get the response of all the process in your organisation as shown below:
Response request
HTTP request using POST method
  • In the sketched area one should enter the organization and in the body we should enter the json format commands to create project.
  • sample body :

{

“name”: “FabrikamTravel”,

“description”: “Frabrikam travel app for Windows Phone”,

“capabilities”: {

“versioncontrol”:{

“sourceControlType”: “Git”

},

“processTemplate”:{

“templateTypeId”: “6b724908-ef14-45cf-84f8-768b5384da45”

}

}

}

In the above sample code use your chosen id from process which you get using http GET request.

  • In this request also give all the basic authorization fields then the response after running the flow will be as follows:
HTTP response using POST Method

Here, new project creation done successfully as see the id, status and url of the new project but status is still showing not set because as it takes some time to do the operation.

To check whether it is created successfully are not , after some time send a http request to show list of projects in your devops organisation using http get method :

GET https://dev.azure.com/{organization}/_apis/projects?api-version=5.1

Using the above url in http request the status of new project can be known.

Hope you find this content of the blog useful and pls comment

Leave a comment