简体   繁体   English

当 Azure 自动化运行手册完成时调用 API

[英]Call API when Azure Automation runbook has completed

I want to call an API to trigger an Azure Automation runbook.我想调用 API 来触发 Azure 自动化运行手册。 I believe this can be done with webhooks.我相信这可以通过 webhook 来完成。 When doing so, I get back 202 response code which suggests that the request was successfully queued .这样做时,我会返回 202 响应代码,表明请求已成功排队

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).现在我试图找出如何指定一个回调 API 调用,Azure 自动化在完成执行后应该触发,包括结果状态(完成,失败)。 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?这个回调是我自己应该在 Azure 自动化作业中编码的,还是有一个默认功能可以在运行手册完成时允许 API 回调?

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.首先,没有默认功能允许在运行手册完成时进行 API 回调。

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.我能想到的最佳解决方案是将回调 api 放在运行手册中。 For example, you can put your code in try - catch - finally code block, and put the api in the finally section.例如,您可以将您的代码放在try - catch - finally代码块中,并将 api 放在finally部分。

Hope it can help.希望它可以提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM