top of page

Service Hooks for Azure DevOps - HTTP request in Power Automate

Hey all.


Hope you are doing well today, Friday and all that jazz! Hope you have some good plans for the weekend.


I am on holiday for the next two weeks. My daughter finishes reception year at Primary school today, so we have some cool stuff planned next week which will involve skate parks, a steam train ride, some archery and a trip to a science fair! Then we are off to Devon for a week, I can't wait!


Introduction


Yesterday I wrote about Application Lifecycle Management and the ALM Accelerator for the Power Platform, this got me thinking about how to use Power Automate to notify people that builds and releases had completed. I wanted to then extend this into Power Automate.


I wanted to try and figure out a way of being able to create a build and then a release by triggering them in Power Automate.


The problem that I ran into is that creating an instant flow which uses the Queue a new build Azure DevOps step, followed by a Create a New Release (another Azure DevOps action) would literally just do that and in parallel with each other.


I don't really want that, as the release could get kicked off before the build has finished. I also didn't want to use a Delay action inside the flow, as I won't always know how long build process will take to complete/succeed.


My cloud flows and Web Hooks


What I needed was a way to tell a Power Automate cloud flow that a build had been successful. Thanks to Expiscornovus in this thread in the Power Automate forums, I was able to achieve this.


I needed to look into Service Hooks. A service hook effectively allows you to trigger an HTTP call via a web hook into Power Automate, that way I could then trigger the release after the build step had successfully completed.


First of all, I created an instant flow that would create my build:



As you can see above the steps are very simple. Once I run the flow, or click the button the build is queued and once at the top of the queue the build is created.


Then, I created another cloud flow, this time with a "When a HTTP request is received" as the trigger step, and then a "Create a new release step":



Save the flow, and then you will be able to copy the HTTP post URL, as you will need this later when you create a service hook.


Then I jumped back over to DevOps and clicked on Project Settings, inside this section I clicked on Service Hooks:



At first, I got an error saying "You do not have sufficient permissions to view or configure subscriptions.", this was because you need to be a member of either the Project Administrators or Project Collection Administrators permissions group in DevOps.


Note: if you need to add yourself into either of these, make sure you sign out of DevOps and sign in again and then you will be able to create a Service Hook.


Creating a service hook is pretty easy, the first one I created was for when a build is successfully created, click on create new service hook and then choose Web hooks and click next as shown below:




Choose Build completed for the "Trigger on this type of event" dropdown, and Build Status should be "Succeeded". I am just creating one for my Build pipeline, but you can select All pipelines here, then click next:



Next, post your HTTP URL that you copied after you saved the Power Automate step above and paste it as indicated in the URL field under Settings inside the Action step of the service hook creation. If there are any username or password inside the fields that follow this they can be removed, then click Next:


You will then be able to test your service hook:



We are now already to go, kick off your build with the Instant cloud flow we created earlier, and after the build has completed successfully, you will then see the service hook 7 days status increment by 1 and your flow to create the release will start




Thanks for reading, I hope this has been helpful, as always email me with any questions (jon@jondoesflow.com) or leave a comment.


Thanks!

818 views0 comments
bottom of page