Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (34 sloc) 1.25 KB
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Documents;
namespace ProcessOrders
public static class StoreOrder
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]HttpRequest req,
databaseName: "MyOrders",
collectionName: "Orders",
CreateIfNotExists = true,
ConnectionStringSetting = "CosmosDBConnection")]
IAsyncCollector<dynamic> outputDocuments,
ILogger log)
log.LogInformation("HTTP trigger StoreOrder function processed a request.");
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
data.confirmationNumber = Guid.NewGuid();
await outputDocuments.AddAsync(data);
return new OkObjectResult("Order stored");
You can’t perform that action at this time.