2
votes

Im trying to figure out how to get Azure Functions route param (segment) using Powershell.

I want somehow to get the method defined in my function.json-file:

{
  "bindings": [
    {
      "name": "req",
      "type": "httpTrigger",
      "direction": "in",
      "authLevel": "function",
      "route": "api/{method}"
    },
    ...
  ]
}

$req = Gives me body if using POST

$req_query_* = Gives me query params but not the segment defined in route.

Thanks in advance

2

2 Answers

0
votes

There might be a better way, but one option is to just read the function.json file directly, as follows:

$Config = Get-Content D:\home\site\wwwroot\<function_name>\function.json -Raw | ConvertFrom-JSON

Where <function_name> is the name of your function.

0
votes

In case someone stumbles upon this. The answer can be found here: https://marckean.com/2017/10/18/powershell-based-azure-functions/

They are stored in variables like $REQ_PARAMS_METHOD