I am trying to call an Azure function (PowerShell script) triggered by a HTTP url from C# code . I would like to pass some values/parameters to the Azure function from the code.
Ideally, I want to pass some user info to the Azure function and the function would run Connect-PnPOnline
with the parameters. So far, the Webhook works but somehow I can't find a way to read data passed from the code. Or probably something went wrong when I tried to send data.
My C# code:
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 Script:
param (
[string]$userId,
[string]$userPassword
)
...
How can I read the object passed to the Azure function? Or is there better way to pass data to an Azure PowerShell function?
Thanks!