Dave
Dave

Reputation: 86

PowerShell Azure Functions $TriggerMetadata Methode is GET but shoud be POST

I'm new to Azure Functions, so it might be something obvious.

Here's what it is:

I have a Powershell Azure Functions HTTP Trigger Function with Pode, which has a GET and a POST route. Now when I send a POST request via Postman, Invoke-WebRequest or any other tool except Azure Test Tool, I end up in the GET route.

My debugging revealed that $TriggerMetadata contains '"Method": "GET"' in these cases. '"Method": "POST"' only when the request comes from Azure Test Tool itself.

I am faced with a riddle. I hope someone can help me.

My Code:

param($Request, $TriggerMetadata)
$endpoint = '/api/Object'

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

Start-PodeServer -Request $TriggerMetadata -ServerlessType AzureFunctions {
    
    # get route that can return data
    Add-PodeRoute -Method Get -Path $endpoint -ScriptBlock {
        Write-Host "$endpoint - Get"
        
        #doing stuff
    }

    # post route to create some data
    Add-PodeRoute -Method Post -Path $endpoint -ScriptBlock {
         Write-Host "$endpoint - Post"

        #doing stuff
    }
}

My function.json:

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "Request",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "Response"
    }
  ]
}

Upvotes: 3

Views: 792

Answers (1)

Dave
Dave

Reputation: 86

I am very sorry, especially since this is very unsatisfactory, but the problem no longer exists.

I strongly suspect that it was a bug in Azure, since I did not change anything and everything is working again.

Time to check the Azure Functions SLA I guesse.

Upvotes: 1

Related Questions