Schedule an Azure Automation Runbook Using Minutes

I was working with a customer recently and we realized that when using the “Schedule” functionality the most granular re-occurrence interval available is 1 hour.  In this particular case, we needed to check service status every 5 minutes and send the data to Log Analytics to alert and trigger a remediation runbook, so 1 hour would not suffice.  I had recently spoken with a member of the product group around a custom Log Analytics solution and specifically remembered him saying that his runbook was running every 5 minutes….so I was off to investigate.

After a few minutes of searching, I was able to find some good information here. Although the post referenced the Classic portal, the same basic process still applies and worked in my scenario.  By using a Scheduler Collection we can schedule at a much more granular interval.  I’ve outlined the process in the new portal below.
  1. Navigate to your Automation Account and select the runbook you would like to schedule.  In this case I am select the testloop runbook.sched1
  2. Select the runbook and then select the “Add webhook” option on the top ribbon bar.  sched12
  3. Enter the Name of the webhook and copy the URL.  You must copy the URL at this point as once the webhook has been created it can no longer be viewed!  pic3
  4. Now that the webhook has been created, we’ll need to create the Scheduler.  Navigate to the “All Services” blade. 
  5. Start typing “Scheduler” in the search field and the option for “Scheduler” will appear. Select “Scheduler Job Collections” and then select the “Create” button at the bottom of the page.
  6. sched3-
  7. On the Scheduler Job blade, enter the name of the job and select “Job collection” to create a new collection.  Select “+ Create New” and proceed to fill out the “New Job Collection” properties.pic5
  8. Next select “Action Settings”.  On the “Action settings” blade enter the Action, Method, and Url (see below).  The Url is the webhook URL copied from step 3 above.  You do not need to fill in the other data.pic6
  9. Lastly, select “Schedule” and configure the scheduling options.  Notice under “Recur every” we can now select minutes.  Much better!Pic9Replace7.png
  10. Once you select the “Create” button, the Job Collection is created.  At this point we can navigate back to the main menu, select “More Services”, and start to enter “Scheduler” in the search field.  You will see “Scheduler Job Collection” appear.  Favorite “Scheduler Job Collections” and select to navigate to the “Scheduler Job Collections blade.Pic8.png
  11. The “Scheduler Job Collection” blade provides in-depth detail about the job status, history, properties, and more.pic9
  12. To verify that the runbook is executing as expected, navigate back to the “Automation Account” blade and select “Jobs”.  You should see your job executing every 5 minutes.2016-10-03_11-53-26

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s