0

I have an existing Devops pipeline that trains ML models. To guaranty the robustness for the models, it will be necessary to retrain it periodically. For this I decided to create an Azure function that will be executed each month. will It collect the new data, apply the data pre-processing and finally trigger the Azure Devops training pipeline. All of this must be done with python. By doing a research, I understood that this can be done using REST Azure Devops API request. I founded this python git repo https://github.com/microsoft/azure-devops-python-api which provides an API to communicate with Azure DevOps. I executed the code provided by this package which displays the list of my devops projects. But I can't found how trigger the pipeline. Assuming that my organisation named ORGA1, the project named PROJ1 and the pipeline that I want ti execute named PIPELINE1, How can I launch it using an Azure function or even a simple python script ? PS: I am using a python 3.9 Timer Trigger Azure function. Thank you in advance for your help.

EDIT

I tired to use LOGIC APP to do this like @mohammed described in the comment and I think that this is a good solution. Above the workflow that I created: enter image description here

So I launch the logic app each X hours, this will trigger the azure Devops, and ASA it end training with Success it will send me an email. I have one error here, is that I am creating a new release and not triggering a specific pipeline each time. But navigating in the different actions under the devops service, I cannot found any thing related to launching a devops pipeline. Can anyone have an idea how to do it.

el abed houssem
  • 350
  • 1
  • 7
  • 16

3 Answers3

1

You can use a Logic App with a timer to trigger your DevOps pipeline instead of an Azure function, as it has all the built-in connectors required to interface with your DevOps. See : https://www.serverlessnotes.com/docs/keep-your-team-connected-using-azure-devops-and-azure-logic-apps

Rimaz Mohommed
  • 1,176
  • 10
  • 16
  • Thank you mohamed. The problem that I have to use Azure Function because I have to do other things that is not related to the devops pipeline. Means not all steps(data acquisition, data preparation...) are included in the pipeline. What I want is , form an Azure function lunch directly or indirectly an azure devops pipeline. – el abed houssem Jun 18 '21 at 13:03
  • 1
    You can run your azure functions as part of the Logic App. Use the Logic app as the orchestrator to first invoke your azure functions, and then run your devops pipelines using the existing connectors.. see here for how to call your azure functions from logic apps : https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-azure-functions – Rimaz Mohommed Jun 18 '21 at 20:43
  • You can also implement your solution such that, your azure function first invokes the Logic app using an HTTP trigger, which in turn uses the devops connectors to run your pipelines – Rimaz Mohommed Jun 18 '21 at 20:47
  • You can read through this documentation to see how to trigger your pipeline using the logic app : https://learn.microsoft.com/en-us/samples/azure-samples/azure-logic-apps-pipeline-orchestration/azure-devops-orchestration-with-logic-apps/ – Rimaz Mohommed Jun 19 '21 at 01:27
1

Thanks to the tips provided by @Mohammed I found a solution. Logic App provides what I am looking for. Under the list of Devops connectors provided the by the Logic App, there is a connector named Queue a new build and this is exactly what I am looking for. This is my first experiment architecture and I will update it later by adding Azure Function service before calling the Devops Pipeline. enter image description here

el abed houssem
  • 350
  • 1
  • 7
  • 16
0

You may try using Azure Durable Functions, you can kind of replicate what a Logic App does while still using Azure Functions. See documentation here 1

  • Thank you @Diego for you quick response. By using your proposed solution, I'm going back to my main problem: ** using python, how to run an azure devops pipeline from an azure function** . If you know how to do it than your solution will the suitable for my use case. – el abed houssem Jun 18 '21 at 14:14