Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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