Search code examples
azurerestpower-automateazure-machine-learning-service

How to trigger Azure ML Pipeline from Power Automate


I have a published Azure ML Pipeline that I am trying to trigger from an Automate Flow I have that triggers when users edit a document. Since I have the REST Endpoint for the Published Pipeline, I figured I should be able to make a POST request using the HTTP module available in Power Automate to trigger the pipeline.

However, when I actually try this, I get an authentication error. I assume this is because I need to include some access token with the REST Endpoint, but I can't find any documentation that will tell me where to get that token from. Please note that I do not need to pass any data to the Pipeline, it handles its own data collection, I literally just need a way to trigger it.

Does anybody know how to trigger a Published Azure ML Pipeline using the REST Endpoint? Does it make sense to use the HTTP module, or is there a better way to achieve this?


Solution

  • So I figured out how to do it by following the directions contained within this piece of Microsoft Documentation: https://learn.microsoft.com/en-us/azure/machine-learning/how-to-manage-rest

    Specifically, it required performing two of the calls in the documentation;

    • The first to get an AAD token using an Azure Service Principle that is authorised to access the Machine Learning Instance.

    curl -X POST https://login.microsoftonline.com//oauth2/token -d "grant_type=client_credentials&resource=https%3A%2F%2Fmanagement.azure.com%2F&client_id=&client_secret="

    • The second to use this token to trigger your pipeline from its rest endpoint. This one I had to figure out myself a little, but below is the basic structure I used.

    curl -X POST {PIPELINE_REST_ENDPOINT} -H "Authorisation:Bearer {AAD_TOKEN}" -H "Content-Type: application/json" -d "{"ExperimentName": "{EXPERIMENT_NAME}","ParameterAssignments": {}}"