public async Task Run([QueueTrigger("outputletter", Connection = "AzureWebJobsStorage")] FormLetter myQueueItem, [Table("letters")] IAsyncCollector <LetterEntity> letterTableCollector, ILogger log) { log.LogInformation($"This is in LogForm, {myQueueItem.ExpectedDate}"); //TODO map FormLetter message to LetterEntity type and save to table storage //Here I am grabbing the information from myQueItem and creating n ew variables to plug into the letterEntity DateTime expect = myQueueItem.ExpectedDate; DateTime request = myQueueItem.RequestedDate; LetterEntity newNote = new LetterEntity(); { newNote.Heading = myQueueItem.Heading; newNote.Likelihood = myQueueItem.Likelihood; newNote.ExpectedDate = expect; newNote.RequestedDate = request; newNote.Body = myQueueItem.Body; }; await letterTableCollector.AddAsync(newNote); log.LogInformation($"C# Queue trigger function processed: {myQueueItem}"); }
public async Task Run([QueueTrigger("outputletter", Connection = "")] FormLetter myQueueItem, [Table("letters")] IAsyncCollector <LetterEntity> letterTableCollector, ILogger log) { Random rand = new Random(); LetterEntity letterEntity = new LetterEntity { Heading = myQueueItem.Heading, Likelihood = myQueueItem.Likelihood, ExpectedDate = myQueueItem.ExpectedDate, RequestedDate = myQueueItem.RequestedDate, Body = myQueueItem.Body, PartitionKey = myQueueItem.Heading.ToLower(), RowKey = ((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds).ToString() + rand.Next(10000, 99000).ToString() // Unix timestamp + random 5 digit integer }; await letterTableCollector.AddAsync(letterEntity); log.LogInformation($"C# Queue trigger function processed: {myQueueItem}"); }