2
votes

When using the Microsoft Sample-Using-RunbookParameter script and running the following Azure Automation PowerShell:

$date = Get-Date
$Params = @{"Name"="World";"Number"=1; "Date"=$date; "SayGoodBye"=$TRUE; "StringArray"="[1,'astringvalue',2]"}
Start-AzureAutomationRunbook -AutomationAccountName CMTEST -Name Sample-Using-RunbookParameters -Parameters $Params

I get the following exception:

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.Boolean' for parameter named 'SayGoodbye'.
'DynamicActivity': Expected an input parameter value of type 'System.DateTime' for parameter named 'Date'.
 jParameter name: rootArgumentValues

If I look in the Azure Automation Job log I see the following input parameters:

DATE Fri, 08 Aug 2014 15:26:14 GMT
NAME World
NUMBER 1
SAYGOODBYE True
STRINGARRAY [1,'astringvalue',2]
2

2 Answers

0
votes

This is due to a bug in the Azure Automation cmdlets that will be fixed in an upcoming Azure PowerShell release (if not the next one, the one after that). Basically, the cmdlet is supposed to serialize each job parameter as json, but is currently passing them as each as a string.

Also, once this is fixed, instead doing the above in your code as you are currently doing:

"StringArray"="[1,'astringvalue',2]"

You will want to use a proper PowerShell array:

$SomeArray = @(1, "astringvalue", 2)
"StringArray"=$SomeArray
0
votes

You can pass BOOLEAN value using $ signature. like below:

$params = @{“AZURERESOURCEGROUP”=”Infra-ResourceGroup”;”SHUTDOWN”=$TRUE}

In above example resourcegroup name will be passed as string into AZURERESOURCEGROUP parameter. To pass BOOLEAN value you can use $TRUE/$FALSE.