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 OMS 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 OMS 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 connectiontest runbook.pic1
  2. On the Runbook settings blade, select Webhooks.  On the Webhooks blade, select “+ Add Webhook”.pic2
  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 main menu and select App Services.  Select the “+ Add” option to add a new App Service.
  5. Start typing “Scheduler” in the search field and the option for “Scheduler” will appear. Select “Scheduler” and then select the “Create” button at the bottom of the page.pic4
  6. 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
  7. 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
  8. Lastly, select “Schedule” and configure the scheduling options.  Notice under “Recur every” we can now select minutes.  Much better!Pic9Replace7.png
  9. 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
  10. The “Scheduler Job Collection” blade provides in-depth detail about the job status, history, properties, and more.pic9
  11. 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

One thought on “Schedule an Azure Automation Runbook Using Minutes

Comments are closed.