Reputation: 1728
Identical question here.
I'm invoking an Azure Logic App job via the Azure API. I need to be able to follow up and get the status of the job to know whether it succeeds or fails.
The answer to post above helpfully points to the Workflow Runs - Get API. That looks like just what I need. However, to get the status of the run, I need the runName
(sounds like request id?). But when I submit the initial request to the Azure API, I don't get a runName or job id. I just get <Response [202]>
. So, I can't subsequently request the status of the run.
To be clear, I'm invoking the logic app by calling the HTTP POST url provided by the trigger of the Logic App. Looks like this:
https://prod-00.northcentralus.logic.azure.com:443/workflows/DELETED/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=DELETED
The response to that endpoint is the Response [202]
mentioned above. No run name provided.
Any pointers would be appreciated!
Upvotes: 0
Views: 2479
Reputation: 2687
You do not get the workflow name when you trigger the logic app. You will see it in the response of the Getworkflow list API call. So you can get the workflow list with a filter on date and time and then fire the get workflow runs API call.
To call the API, you will need a bearer token. First register an app/service principal with Azure AAD (Link). Give the app/service principal the proper role on the Logic app. You can give a Reader role. Then make a call to the https://login.microsoftonline.com/<tenant_id>/oauth2/token endpoint to fetch the bearer token. You will need the tenant id, client id and client secret. See the snapshot for reference.
Add the bearer token under a Authorization header when making the Logic app API call.
But maybe you can check and confirm the necessity of triggering the logic app asynchronously. Instead you can trigger the logic app synchronously. For this you will need to make some changes in the Logic app itself. You can refer to this SO response to get an idea on how to do this.
With this change, you will not need to check the status. You will get a response as soon as the Logic app completes. Of course this depends on how long the Logic app roughly runs for.
Upvotes: 1