-
-
Save justinyoo/48428097739603197cb81816f720d8e9 to your computer and use it in GitHub Desktop.
Precompiled Azure Functions Revisited
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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