You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Azure Automation Runbook Webhook请求体传递至Logic Apps

Solution: Pass Webhook Request Body to Logic Apps from Azure Automation Runbook

Key Issue with Current Code

Your existing code uses a GET request to invoke Logic Apps, which doesn’t support sending a request body. To pass the full Webhook request content, you need to switch to a POST request and include the body in the request payload.

Modified Runbook Code

Here’s the updated PowerShell code that sends the complete Webhook request body to your Logic Apps HTTP trigger:

param
(
    [Parameter(Mandatory=$false)]
    [object] $WebhookData
)

if ($WebhookData.RequestBody) { 
    # Parse the Webhook request body to ensure valid JSON structure
    $parsedRequestBody = ConvertFrom-Json -InputObject $WebhookData.RequestBody
    
    # Convert parsed object back to JSON with sufficient depth for nested fields
    $jsonPayload = ConvertTo-Json $parsedRequestBody -Depth 10

    # Logic Apps HTTP trigger URI (replace {signature_certificate} with actual valid signature)
    $logicappURI = "https://logicapp/api/test/triggers/manual/invoke?api-version=2022-05-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig={signature_certificate}"

    # Send POST request with the full request body payload
    $response = Invoke-WebRequest -Method POST `
                                  -Uri $logicappURI `
                                  -Body $jsonPayload `
                                  -ContentType "application/json"

    Write-Output "Logic Apps invoked successfully. Response status: $($response.StatusCode)"
}
else {
    Write-Output "No Webhook request body received."
}

Key Changes Explained

  • POST Request Instead of GET: GET requests can’t carry a request body, so POST is used to send the full payload to Logic Apps.
  • JSON Payload Handling: Parsing and re-serializing the Webhook request body ensures valid JSON formatting, and -Depth 10 handles nested structures like the RequestHeader object.
  • Content-Type Header: Setting application/json tells Logic Apps to expect and parse JSON data natively.

Logic Apps Configuration

In your Logic Apps HTTP trigger, access the full request body using the expression triggerBody(). For specific fields:

  • Get the Webhook name: triggerBody()?['WebhookName']
  • Parse the stringified RequestBody array: json(triggerBody()?['RequestBody']) (since the RequestBody field in your example is a stringified array)

Notes

  • Ensure your Logic Apps HTTP trigger allows POST requests (enabled by default for manual triggers).
  • Adjust the -Depth parameter in ConvertTo-Json if your request body has deeper nested structures than shown.
  • Replace {signature_certificate} in your Logic Apps URI with the actual valid signature from your Logic Apps endpoint.

内容的提问来源于stack exchange,提问作者Abdulquadir Shaikh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 15:54:42