通过Azure API,门户或ISE附加组件启动Runbook会产生“输入参数类型不匹配"的错误消息.错误 [英] Starting Runbook via Azure API, Portal, or ISE Add-On yields "input parameter type mismatch" error

查看:109
本文介绍了通过Azure API,门户或ISE附加组件启动Runbook会产生“输入参数类型不匹配"的错误消息.错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个简单的运行手册:

Given a simple runbook:

workflow test
{
    [CmdletBinding()]
    param([string] $NumericString)

    write-output $NumericString
}

当通过Azure门户以数字值(即5)作为新作业(通过发布),通过测试窗格或使用Azure Automation PowerShell ISE加载项启动它时,将返回以下错误,并且执行失败.

When starting it with a numeric value (ie: 5) via the Azure Portal as a new Job (published), via the Test Pane, or using the Azure Automation PowerShell ISE Add-On, the following error is returned and the execution Fails.

[edit]出于好奇,我尝试了其他一些方法. "true"或"false"(在ise/ui中没有引号)也会导致错误(并在引号内发送到API).[\ edit]

[edit] Just out of curiosity I tried some other values. 'true' or 'false' (without quotes in ise/the ui) will also cause the error (and are sent to the API inside quotes).[\edit]

为根活动的参数提供的值不满足 根活动的要求:'DynamicActivity':预期输入 参数"Numeric"的类型为"System.String"的参数值. 参数名称:rootArgumentValues

The values provided for the root activity's arguments did not satisfy the root activity's requirements: 'DynamicActivity': Expected an input parameter value of type 'System.String' for parameter named 'Numeric'. Parameter name: rootArgumentValues

AFAIK,当我通过父级Runbook,Webhook等执行时,这不是一个因素.

AFAIK, this is not a factor when I've executed via a parent runbook, webhook, etc.

PowerShell ISE附加组件向API发出以下PUT请求: (https://management.azure.com/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Automation/automationAccounts/<aa>/runbooks/<rb>/draft/testJob?api-version=2015-10-31)

The PowerShell ISE Add-On issues this PUT request to the API: (https://management.azure.com/subscriptions/<id>/resourceGroups/<rg>/providers/Microsoft.Automation/automationAccounts/<aa>/runbooks/<rb>/draft/testJob?api-version=2015-10-31)

{
    "parameters": {
        "Numeric": "5"  <-- notice it's a string
    }
}

推荐答案

这似乎是一个错误,类似于 Azure自动化错误' DynamicActivity":预期输入参数的类型为

This would appear to be a bug, similar to Azure Automation Error 'DynamicActivity': Expected an input parameter value of type

要缓解此问题,只需在门户或ISE插件中将数字值括在引号中

To mitigate the issue, just wrap your numeric value in quotes in the Portal or ISE Add-On

如果要在正式的SDK之外启动运行手册,则似乎需要了解有关发送字符串参数的数字或布尔值(至少)的所需额外转义.

If you are starting runbooks outside of the formal SDKs, it appears you need to know about required extra escaping for sending Numeric or Boolean values for string parameters (in the least).

这是后续的PUT请求的外观(来自ISE附加组件)

This is what the subsequent PUT request should look like (from ISE Add-On)

{
    "parameters": {
        "Numeric": "\"5\""  
    }
}

这篇关于通过Azure API,门户或ISE附加组件启动Runbook会产生“输入参数类型不匹配"的错误消息.错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆