How to schedule runbook based on minutes in Azure automation Account

2.2k Views Asked by At

How to schedule automatically execute runbooks based on minutes instead of hours in Microsoft azure automation account?

2

There are 2 best solutions below

1
On BEST ANSWER

hm, I thought this was possible, but it appears not. you can create multiple hourly schedules for this (if you want it to start every 10 minutes - create 6 hourly schedules), you can create an azure function timer triggered and just start your runbook with that (more hacky, I guess) or create an external event that would start the runbook using the Azure API or, perhaps, via a webhook

0
On

Sadly you have to create 60 schedules 1 for each minute to reoccur every hour. Luckily Powershell is here to help:

$AutomationAccountName = ""
$ResourceGroupName = ""
$Subscription = ""
$tenant = ""
$runbookName = ""

Connect-AzAccount -Tenant $tenant -Subscription $Subscription

$i = 0
While($i -le 59){
    $StartTime = Get-Date "16:$($i):00"
    $Name = "EveryMinute $($i)"
    $i++

    $schedule = New-AzAutomationSchedule -AutomationAccountName $AutomationAccountName -Name $Name -StartTime $StartTime -HourInterval 1 -ResourceGroupName $ResourceGroupName 
    $Register = Register-AzAutomationScheduledRunbook -AutomationAccountName $automationAccountName -Name $runbookName -ScheduleName $Name -ResourceGroupName $ResourceGroupName
}