Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created April 29, 2017 23:18
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/48428097739603197cb81816f720d8e9 to your computer and use it in GitHub Desktop.
Save justinyoo/48428097739603197cb81816f720d8e9 to your computer and use it in GitHub Desktop.
Precompiled Azure Functions Revisited
using System.Configuration;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
using PrecompiledSample.EntityModels;
using PrecompiledSample.Models;
using PrecompiledSample.Services;
namespace PrecompiledSample.Functions
{
public static class AddProductQueueTrigger
{
public static async void Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
var model = JsonConvert.DeserializeObject<ProductModel>(myQueueItem);
var connectionString = ConfigurationManager.ConnectionStrings["PrecompiledDbContext"].ConnectionString;
var dbContext = new PrecompiledDbContext(connectionString);
var service = new ProductService(dbContext);
var result = await service.SaveAsync(model).ConfigureAwait(false);
log.Info("Queue has been processed");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment