I have the following health check / status method in my Azure function app: (v4)
public static class HealthStatus
{
[FunctionName("HealthStatus")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "health/status")] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string qn = req.Query["qn"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
qn = qn ?? data?.name;
string responseMessage = string.IsNullOrEmpty(qn )
? "qn : All. Status OK"
: $"qn : {qn }. Status OK";
return new OkObjectResult(responseMessage);
}
}
Locally when I run a GET on this, i get the "All. Status OK" method. Upstream, after I publish to azure, when i use the "code & test" option in azure to try to run this function, it only works if I GET with a query string parameter called qn. Otherwise, instead of a 200 OK, I get a "500 internal server error". The logs show this error:
2022-06-14T17:49:36.042 [Information] C# HTTP trigger function processed a request.
2022-06-14T17:49:36.150 [Error] Executed 'HealthStatus' (Failed, Id=asdf-e859-asdf-asdf-asdf123123, Duration=78ms)'string' does not contain a definition for 'name'
Any tips as to why the results are different and how I can fix would be appreciated.