Created
December 17, 2021 08:02
-
-
Save beachside-project/53462108fced3f58022bd14b6ca1e232 to your computer and use it in GitHub Desktop.
Function app default code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Function1 | |
{ | |
[FunctionName("Function1")] | |
public static async Task<IActionResult> Run( | |
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, | |
ILogger log) | |
{ | |
log.LogInformation("C# HTTP trigger function processed a request."); | |
string name = req.Query["name"]; | |
string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); | |
dynamic data = JsonConvert.DeserializeObject(requestBody); | |
name = name ?? data?.name; | |
string responseMessage = string.IsNullOrEmpty(name) | |
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response." | |
: $"Hello, {name}. This HTTP triggered function executed successfully."; | |
return new OkObjectResult(responseMessage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment