Skip to content

Instantly share code, notes, and snippets.



Last active Nov 7, 2018
What would you like to do?
Azure Functions - Part 4: Working with Persistent Data and Visual Studio Code - 2
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
[Table("UserData")] out UserData ud,
ILogger log)
log.LogInformation("C# HTTP trigger function processed a request.");
string text = req.Query["text"];
string requestBody = new StreamReader(req.Body).ReadToEnd();
dynamic data = JsonConvert.DeserializeObject(requestBody);
text = text ?? data?.text;
ud = new UserData
PartitionKey = "1",
RowKey = DateTime.Now.Ticks.ToString(),
Text = text
return text != null
? (ActionResult)new OkObjectResult($"Hello, {text}")
: new BadRequestObjectResult("Please pass some text on the query string or in the request body");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment