question

CalderaraSerge-8943 avatar image
0 Votes"
CalderaraSerge-8943 asked stan commented

How to trigger an Azure Automation Script when a Job Status change

Dear all,

Is there a way to get a script in Azure automation which is trigger when a given Job status change ?
That script will call an external Jira API which will then update a status inside a Jira issue

Thanks for help
regards

azure-automation
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

stan avatar image
0 Votes"
stan answered stan commented

Hi,
If I understand correctly (correct me if I am wrong) you want to trigger something when a runbook job status is changed. By default, there is no such thing but here are some suggestions:

  • have some custom script/code that runs periodically and checks for changes. There is a job API for Azure Automation jobs. Of course, this requires some custom code to accommodate to the logic for what you are trying to achieve.

  • Automation account has diagnostic logs for jobs. You can send those to Event Hub/Log Analytics/ Storage account. For any of those you will have to do some custom integration to achieve the desired effect. Log Analytics have alerts which trough action groups trigger webhook, some Azure services or built-in notifications. If you can create Log Alert based on Kusto query language that achieve the desired result you can use that.

With any of the options you will have to have some custom code in order to interact with the Jira API.

Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thnaks @stan for your reply.

We are actually trying to avoid a pooling base approach.

Based on the Alert we have seen that but once think we cannot find for the Alert and Action Group is that when you define criteria for the Alert we absolutely need to have in the criteria the Job Id.

The reason for that is that we might check for a particular RunBook job to status change.

For exemple a Runbook can be start 2 or 3 times for different environment, but we want to check the status for a particular one with precision and without the JobId we are not able to be sure above the job we monitor.


Any idea or trick to get that Id in the criteria or is it definitely not possible ?

regards

0 Votes 0 ·
stan avatar image stan CalderaraSerge-8943 ·

When the logs are send to Log Analytics job ID is available in column JobId_g. Log Alert v1 will send the results from the query in the webhook. In Log Alert v2 in order for the column to be available in the webhook you will need to add it in dimensions.

0 Votes 0 ·

hello @stan ,

I am lost now, do you have a capture of what you are trying to explain or video records somewhere ?

Just to be sure we are on same line. let say I have 2 Job with Id 1 and 2 and I need to monitor when Job 1 is completed.

criteria would be something like JobId=1 and status=Completed Then it will run my script only once

0 Votes 0 ·
Show more comments