【问题标题】:Azure Automation Runbook fails triggered with Webhook "Missing argument in parameter list"使用 Webhook“参数列表中缺少参数”触发 Azure 自动化 Runbook 失败
【发布时间】:2022-01-01 10:06:12
【问题描述】:

我在 Azure 自动化帐户中放置了一个相当简单的脚本,用于停止 Azure 容器实例。当我测试它或单击开始按钮时,我从门户顺利运行,没有产生错误并正确完成工作。 '''

Param
(
  [parameter (Mandatory=$false)]
  [object]$WebhookData
)

try
{
    "Logging in to Azure..."
    Connect-AzAccount -Identity
}
catch {
    Write-Error -Message $_.Exception
    throw $_.Exception
}

$ACIs = Get-AzContainerGroup

foreach ($ACI in $ACIs)
{    
    Write-Output ("Shutting down the following Azure Container Instance:  " + $ACI.Name)
    Stop-AzContainerGroup -Name $ACI.Name -ResourceGroupName 'MY_RESOURCE_GROUP_NAME'
    Write-Output ("")
}

我创建了一个 webhook 来启动该脚本。每当我发送发布请求以触发该脚本时,它都会失败并出现以下错误: '''

ParserError:
Line |
| … .ps1' -WebhookData {WebhookName:XXXX,RequestB …
| ~
| Missing argument in parameter list.

我尝试在消息正文中添加某项内容,从 PowerShell 和 Postman 发送请求。我收到了 JobIds 和状态码 202 的回复。我一直在寻找类似的问题,但我得到的唯一问题是 one 没有回答。

有什么想法吗?

【问题讨论】:

    标签: azure webhooks azure-powershell azure-automation


    【解决方案1】:

    问题出在 Azure 自动化 Runbook 中的 Powershell 版本。使用 Powershell 5.1 解决了这个问题。看起来,当 Runbook 使用 Powershell 7.1 时,它存在一些格式问题:link

    【讨论】:

      猜你喜欢
      • 2020-09-16
      • 1970-01-01
      • 2016-06-22
      • 2021-12-01
      • 2018-06-12
      • 2019-03-15
      • 1970-01-01
      • 2022-01-18
      • 1970-01-01
      相关资源
      最近更新 更多