BICEP:创建 Azure 自动化帐户 Runbook 计划链接因“错误请求”而失败

问题描述 投票:0回答:1

我正在尝试使用二头肌将时间表链接到操作手册。它失败并显示错误“错误请求”并且不提供其他信息。任何人都可以帮助解决我在这里做错的事情吗?计划和操作手册都存在于自动化帐户内。

我已遵循 Azure 文档和示例,因此我希望代码能够正常工作,但我只收到“错误请求”

`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'
    }
  }
}`
azure azure-devops azure-bicep
1个回答
0
投票

您提供的 Bicep 代码片段似乎大部分是正确的,但有一些潜在的问题可能导致“错误请求”错误:

缺少 Runbook ID:将计划链接到 Azure 自动化中的 Runbook 时,需要提供 Runbook 的完整资源 ID,而不仅仅是其名称。可以使用 Azure CLI 或 PowerShell 检索 Runbook 的资源 ID。 计划名称不正确:确保您引用的计划名称(“myschedule”)与您尝试链接到 Runbook 的计划名称匹配。 无效的计划参数:如果您的 Runbook 需要参数,则需要在作业计划资源的参数字段中提供它们。 这是解决这些问题的二头肌代码片段的更新版本:

param automationAccountName string
param runbookName string
param scheduleName string

resource automationAccount 'Microsoft.Automation/automationAccounts@2022-08-08' existing = {
  name: automationAccountName
}

// Retrieve the runbook resource ID
var runbook = resourceId('Microsoft.Automation/automationAccounts/runbooks', automationAccountName, runbookName)

resource job_schedule 'Microsoft.Automation/automationAccounts/jobSchedules@2022-08-08' = {
  name: '${automationAccountName}/test-schedule-xxxxxxxxxxxxxxxxxxxxxx'
  properties: {
    parameters: {} // Provide parameters here if needed
    schedule: {
      name: scheduleName
    }
    runbook: {
      id: runbook
    }
  }
}

确保分别将 runbookName 和 ScheduleName 参数替换为 Runbook 和计划的实际名称。此外,请确保 runbookName 参数与您尝试链接到的 Runbook 的名称匹配。

© www.soinside.com 2019 - 2024. All rights reserved.