简体   繁体   English

如何在Azure Functions中将GET与PowerShell一起使用?

[英]How do I use GET with PowerShell in Azure Functions?

The HTTP Trigger sample for PowerShell uses POST but I need to be able to use GET. PowerShell的HTTP触发器示例使用POST,但我需要能够使用GET。 The software I want to integrate with can only do GET. 我要集成的软件只能执行GET。

The example begins with: 该示例开始于:

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

I tried /api/MyFunction?code=stuffstuffstuff==&param1=asdf&param2=1234 expecting that $requestBody would be param1=asdf&param2=1234 . 我尝试了/api/MyFunction?code=stuffstuffstuff==&param1=asdf&param2=1234期望$requestBodyparam1=asdf&param2=1234 Instead, it's just empty. 相反,它只是空的。

I looked at the JavaScript example and had no trouble doing this. 我看了看JavaScript示例,这样做很容易。 On a GET request the querystring parameters are available in req.query vs POST which is req.body . 在GET请求中,querystring参数在req.query vs POST(即req.body

Has this possibly not been implemented for PowerShell yet? 这可能尚未为PowerShell实施吗?

Use $req_query_param1 and $req_query_param2 variables 使用$req_query_param1$req_query_param2变量

Invoke URL: 调用网址:

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

Function code: 功能码:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用powershell获取azure函数中的出队计数 - how to get the dequeue count in azure functions with powershell 如何在Powershell中从Azure获取VM映像? - How do I get a VM Image from Azure in Powershell? 如何使用 Powershell 从 Azure Functions 获取 Azure Blob Uri? - How to get the Azure Blob Uri from Azure Functions with Powershell? 如何从我的 Azure 函数引用其他 powershell 函数? - How do I reference other powershell functions from my Azure Function? 如何获取要在PowerShell脚本中使用的文件的位置? - How do I get the location of a file to use in my PowerShell script? 如何在 PowerShell 中获取 StreamWriter 以创建文件并使用它? - How do I get StreamWriter in PowerShell to create a file and use it? 如何在 powershell 脚本中使用 Get-clipboard output? - How do i use Get-clipboard output in a powershell script? 如何找到 Azure PowerShell 版本? - How do I find the Azure PowerShell version? Powershell:如何从 Azure Active Directory 用户获取名称 (Get-AzADUser) - Powershell: How do I get the name from Azure Active Directory user (Get-AzADUser) 如何使用变量或函数来记住Powershell中提示的输入? - How do I use variables or functions to remember the input from a prompt in Powershell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM