-1

I have 5 parameters {[string]$VMName, [string]$ResourceGroupName, [string]$UserName, [string]$Paswd, [string]$UserDirectory, [string]$RequestType} in my runbook code what will be Webhookdata input parameter(json) syntax in Azure ?

VenkateshDodda
  • 4,723
  • 1
  • 3
  • 12

1 Answers1

0

if you want to pass Json object to the runbook you need to follow the below steps :

  1. You need to create a JSON file that contains all parameters & save it as test.json file.

     {
          "VMName" : "",
          "ResourceGroupName" : "",
          "UserName" : "",
          "Paswd" : "",
          "UserDirectory" : "",
          "RequestType" : ""
     }   
    
  2. convert the JSON code to a string

    $json = (Get-content -path 'JsonPath\test.json' -Raw) | Out-string

  3. Convert the string to a PowerShell object before passing it to the runbook.

    $JsonParams = @{"json"=$json}

  4. Create a hash table for the parameters

$RBParams = @{
             AutomationAccountName = '<AutomationAccountName'
             ResourceGroupName = '<resourcegroup_name>'
             Name = 'Test-Json'
             Parameters = $JsonParams
        }
  1. Start the run book
 $job = Start-AzAutomationRunbook @RBParams

For more information you can refer this documentation.

VenkateshDodda
  • 4,723
  • 1
  • 3
  • 12