Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active April 29, 2017 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/aba113838ded074dea58cd9b56114890 to your computer and use it in GitHub Desktop.
Save justinyoo/aba113838ded074dea58cd9b56114890 to your computer and use it in GitHub Desktop.
Precompiled Azure Functions Revisited
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace PrecompiledSample.Functions
{
public static class AddProductHttpTrigger
{
// Make sure this SHOULD always be static.
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, IAsyncCollector<string> outputQueues, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
var body = await req.Content.ReadAsStringAsync().ConfigureAwait(false);
// Loads request body to the queue.
await outputQueues.AddAsync(body).ConfigureAwait(false);
// Make sure it returns HTTP Status Code of 202 (Accepted).
return req.CreateResponse(HttpStatusCode.Accepted);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment