I want to call an API to trigger an Azure Automation runbook. I believe this can be done with webhooks. When doing so, I get back 202 response code which suggests that the request was successfully queued.
Now I'm trying to find out how I can specify a call-back API call that the Azure Automation should trigger once it has finished the execution, including the result status (completed, failed). Is this call-back something I should code in the Azure Automation job myself, or is there a default functionality available that would allow an API call-back when the runbook completes?
I'm trying to avoid that my client application which triggered the automation job would have to continuously poll to see if the automation job is still running.
First, there is no default functionality that would allow an API call-back when runbook completes.
And as you may know, we can do this behavior via writing code to check it's status or setup an alert when it's completed. But it would have latency or need poll periodically.
The best solution I can think of is that put the call-back api in the runbook. For example, you can put your code in try - catch - finally
code block, and put the api in the finally
section.
Hope it can help.