コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }