How to webhook in Azure function app in PowerShell

Tanmoy Das 796 Reputation points


Can I please get some help on azure function app using PowerShell.

How to use Webhook to get input in Azure powershell function app

using namespace System.Net

param($Request, $TriggerMetadata)

Write-Host "PowerShell HTTP trigger function processed a request."

$name = $Request.Query.Name
if (-not $name) {
$name = $Request.Body.Name

$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."

if ($name) {
$body = "Hello, $name. This HTTP triggered function executed successfully."

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body


Please suggest

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
2,610 questions
No comments
{count} votes

Accepted answer
  1. Pramod Valavala 14,546 Reputation points Microsoft Employee

    anonymous user the sample function generated highlights how you can access the query parameters and the body of the request (via the $Request variable). If you are dealing with JSON payloads, it is parsed for you.

    You can refer the other properties of the both the request and response objects in the docs.

    No comments

2 additional answers

Sort by: Most helpful
  1. OliverR-82 1 Reputation point

    Hi, I am having difficulties getting the Webhook action to work with an Azure (Powershell) function. More specifically, I don't know how to respond back to the Power Automate flow. I am trying to get the sample script to work with the added last line to respond to Power Automate. Is this (Invoke-RestMethod) the right way to do it?

    using namespace System.Net  
    # Input bindings are passed in via param block.  
    param($Request, $TriggerMetadata)  
    # Write to the Azure Functions log stream.  
    Write-Host "PowerShell HTTP trigger function processed a request."  
    # Interact with query parameters or the body of the request.  
    $targetSite = $Request.Query.TargetSite  
    $callbackUrl = $Request.Query.callbackURL  
    # Write out the queue message and insertion time to the information log.  
    Write-Host "Received provisioning request for site: $targetSite"  
    Write-Host "Received callback url: $callbackUrl"  
    $status = [HttpStatusCode]::OK  
    #$body = "Provisioning to $targetSite succeeded"  
    $Result = Invoke-RestMethod -Uri $callbackUrl -Method Post -body $status  

    The above code is failing with the following error message:

    The request must be authenticated only by Shared Access scheme

    This is what the Power Automate flow looks like so far, just for testing purposes:

    I am not a developer. I'm an IT professional proficient with the Power Platform but not in writing functions. Any help with this would be greatly appreciated.

  2. Magnus Jakobsen 6 Reputation points

    Did you ever solve your issue? I'm in the exact same position now.


    No comments