如何在 Azure Functions 中将 GET 与 PowerShell 结合使用?

How do I use GET with PowerShell in Azure Functions?

PowerShell 的 HTTP 触发器示例使用 POST,但我需要能够使用 GET。我要集成的软件只能做GET。

示例开头为:

$requestBody = Get-Content $req -Raw | ConvertFrom-Json

我试过 /api/MyFunction?code=stuffstuffstuff==&param1=asdf&param2=1234,预计 $requestBody 会是 param1=asdf&param2=1234。相反,它只是空的。

我查看了 JavaScript 示例,没有遇到任何问题。在 GET 请求中,查询字符串参数在 req.query 和 POST 中可用,即 req.body.

这可能还没有为 PowerShell 实现吗?

使用 $req_query_param1$req_query_param2 变量

调用URL:

https://<your funcname>.azurewebsites.net/api/HttpTriggerPowerShell1?code=<your code>&test1=test2

函数代码:

$requestBody = Get-Content $req -Raw | ConvertFrom-Json

if ($req_query_test1) 
{
    $name = $req_query_test1 
}
Out-File -Encoding Ascii -FilePath $res -inputObject "Hello $name"