public async static Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "tableMRNotes")] HttpRequest req, [Table("mrnotes", Connection = "AzureWebJobsStorage")] CloudTable notesTable, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); if (_dataSource == null) { _dataSource = new TableStorageDataSource(notesTable); } var notes = await _dataSource.GetNotesAsync(); return(new OkObjectResult(notes)); }
public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "tableMRNotes")] HttpRequest req, [Table("mrnotes", Connection = "AzureWebJobsStorage")] CloudTable notesTable, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); if (_dataSource == null) { _dataSource = new TableStorageDataSource(notesTable); } string requestBody = new StreamReader(req.Body).ReadToEnd(); var data = JsonConvert.DeserializeObject <MRNote>(requestBody, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Utc }); await _dataSource.AddNoteAsync(data); return(new OkObjectResult(data)); }