I am trying to link a schedule to a runbook using bicep. It fails with the error "Bad Request" and give no other information. Can anyone help with what I am doing wrong here?? The schedule and runbook both exist inside the automation account.
I have followed the Azure documentation and examples so I would expect the code to work but I only receive "Bad Request"
`param automationAccountName string
resource automation_account 'Microsoft.Automation/automationAccounts@2022-08-08' existing = {
name: automationAccountName
}
resource job_schedule 'Microsoft.Automation/automationAccounts/jobSchedules@2022-08-08' = {
name: 'test-schedule-xxxxxxxxxxxxxxxxxxxxxx'
parent: automation_account
properties:{
parameters: {} //scheduleParams
schedule: {
name: 'myschedule'
}
runbook: {
name: 'CheckFileExistsTest'
}
}
}`
2
Answers
The Bicep code snippet you provided seems mostly correct, but there are a few potential issues that could be causing the "Bad Request" error:
Missing Runbook ID: When linking a schedule to a runbook in Azure Automation, you need to provide the full resource ID of the runbook, not just its name. You can retrieve the runbook’s resource ID using Azure CLI or PowerShell.
Incorrect Schedule Name: Ensure that the schedule name you’re referencing (‘myschedule’) matches the name of the schedule you’re trying to link to the runbook.
Invalid Schedule Parameters: If your runbook expects parameters, you need to provide them in the parameters field of the job schedule resource.
Here’s an updated version of your Bicep code snippet addressing these points:
Make sure to replace runbookName and scheduleName parameters with the actual names of your runbook and schedule, respectively. Additionally, ensure that the runbookName parameter matches the name of the runbook you’re trying to link to.
JobSchedule name must be the ‘uuid‘ string, can not be arbitray. if name is not formated with ‘uuid‘, will throw the error
BadRequest
without any additional messages.I have already test at my side, works well.