【发布时间】:2023-03-27 08:05:01
【问题描述】:
我正在尝试调用由 C# 代码中的 HTTP url 触发的 Azure 函数(PowerShell 脚本)。我想从代码中将一些值/参数传递给 Azure 函数。
理想情况下,我想将一些用户信息传递给 Azure 函数,该函数将使用参数运行 Connect-PnPOnline。到目前为止,Webhook 可以工作,但不知何故,我找不到从代码中读取数据的方法。或者当我尝试发送数据时可能出现问题。
我的 C# 代码:
string theUrl = "https://xxxxxx.azurewebsites.net/api/xxxx?code=xxxx==";
var userInfo = new
{
userId = $"ooooo",
userPassword = $"xxxxxxxx"
};
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri(theUrl));
HttpResponseMessage response = await client.PostAsJsonAsync(theUrl, userInfo);
Powershell 脚本:
param (
[string]$userId,
[string]$userPassword
)
...
如何读取传递给 Azure 函数的对象?还是有更好的方法将数据传递给 Azure PowerShell 函数?
谢谢!
【问题讨论】:
标签: c# azure powershell sharepoint azure-functions