Rohit Kulkarni 686 Reputation points

Hello Team, I am running the PowerShell script in PowerShell function in Azure .Please refer below the screenshot ![74724-image.png][1] 1.Withoutsaving the script it is working fine.Please refer the screenshot below : ![74649-image.png][2] 2.After saving the script and try to run I am getting error .Please refer the screenshot below : ![74653-image.png][3] [1]: /api/attachments/74724-image.png?platform=QnA [2]: /api/attachments/74649-image.png?platform=QnA [3]: /api/attachments/74653-image.png?platform=QnA

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

2 answers

Sort by: Most helpful
  1. MayankBargali-MSFT 69,971 Reputation points

    Hi anonymous user

    Welcome to Microsoft Q&A! Thanks for posting the question.

    If you check your first screenshot you have written some piece of code that is not saved and when you try to run that the last saved code (default code when you create any trigger) was executed. That is the reason you will see in the output the message as "Hello, Azure. This HTTP triggered function executed successfully." The default code is as below:

    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.  
    $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."  
    # Associate values to output bindings by calling 'Push-OutputBinding'.  
    Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{  
        StatusCode = [HttpStatusCode]::OK  
        Body = $body  

    The error is the expected in your error screenshot as you have removed the param($Request, $TriggerMetadata) to get the metadata and the function couldn't execute and throws 500 error. You can review Azure function HTTP trigger to learn more about configuration and working.

  2. Vaibhav Chaudhari 38,681 Reputation points

    Not sure on this issue but you can think of running PowerShell script in Azure automation as well. It should more easy there and it is also possible to call this Azure automation runbook in data factory if it has to run on schedule

    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav