Starting Runbook via Azure API, Portal, or ISE Add-On yields “input parameter type mismatch” error

∥☆過路亽.° 提交于 2020-01-06 20:13:01

问题


Given a simple runbook:

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

    write-output $NumericString
}

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] 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]

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, this is not a factor when I've executed via a parent runbook, webhook, etc.

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


回答1:


This is a bug in the Automation portal and ISE add on. For portal, this should be fixed in a week or so. For ISE add on, can you please file a bug on this here: https://github.com/azureautomation/azure-automation-ise-addon/issues




回答2:


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

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

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

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

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


来源:https://stackoverflow.com/questions/35640552/starting-runbook-via-azure-api-portal-or-ise-add-on-yields-input-parameter-ty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!