An Azure service that provides an event-driven serverless compute platform.
Fabian Homann Thanks for posting your question in Microsoft Q&A. Based on your reference to run.csx, I assume you are creating this function via azure portal as C# script. Correct me if that's not the case.
You can simply define bindings like HTTP trigger in function.json and pass the name req in the argument without needing to add HttpTrigger attribute. Check out HTTP trigger doc for detailed info which has example like below:
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = String.Empty;
using (StreamReader streamReader = new StreamReader(req.Body))
{
requestBody = await streamReader.ReadToEndAsync();
}
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
However, if you are using in-process model (or isolated model), then HttpTriggerAttribute is required as described in https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=python-v2%2Cin-process%2Cnodejs-v4%2Cfunctionsv2&pivots=programming-language-csharp#attributes.
I hope this helps and let me know if you have any questions.
Update:
Fabian Homann resolved the issue after removing HttpTrigger attribute and fixed static class in the code.