Hi @Raj D ,
Thank you for the clarification. I now understand that you are trying to invoke a Runbook with parameters using webhook and it needs to run on "Hybrid Worker Group". Based on the sample provided in the questions, below are the changes required to get it to work:
1. Since you are passing parameters when invoking the runbook, the parameter name in the runbook script has to be WebhookData. The invocation engine matches the parameter passed to webhook URI to the named parameter WebhookData
. In your case, you have named it json
, hence the binding cannot happen, causing the error. Please see this link for details.
2. The parameters passed are available to runbook using $WebhookData.RequestBody
. Please find below the sample runbook script with these changes
Param(
[parameter(Mandatory=$false)]
[object]$WebhookData #the pamater for biding passed parameter
)
# Convert object to actual JSON. Note that "WebhookData.RequestBody" is being used to convertFrom-Json
$json = $WebhookData.RequestBody | ConvertFrom-Json
write-output "Passed Parameters" #Output to test that param was passed successfully.
write-output $json.VMName
write-output $json.ResourceGroup
$comp = $env:COMPUTERNAME #this is to test the computer where it ran. It the output is "CLIENT" - then it ran in Azure sandbox
write-output "This RB ran on: $comp"
3. To ensure that runbook job runs on Hybrid runbook worker, it will have to be set in WebHook Parmaeters, as shown below:
Please let me know if you have any questions.
---
Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.