Search code examples
azureazure-bicep

BICEP: Creating Azure Automation Account runbook schedule link fails with "bad request"


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'
      }
  }
}


Solution

  • 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.

    enter image description here

    I have already test at my side, works well.

    param automationAccountName string = 'wbautoaccounttest'
    
    param guidValue string = newGuid()
    
    resource automation_account 'Microsoft.Automation/automationAccounts@2023-11-01' existing = {
      name: automationAccountName
    }
    
    resource job_schedule 'Microsoft.Automation/automationAccounts/jobSchedules@2023-11-01' = {
      name: guidValue
      parent: automation_account
      properties:{
        parameters: {}
        schedule: {
          name: 'wbtest'
        }
        runbook: {
          name: 'wbtestrunbook'
          }
      }
    }
    
    

    enter image description here