Пример #1
0
        public static void Run([QueueTrigger("orders", Connection = "storconnstr")] QueueItem queue
                               , ILogger log)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);

            // Create a table client for interacting with the table service
            CloudTableClient          tableClient = storageAccount.CreateCloudTableClient(new TableClientConfiguration());
            TableQuery <OrdersEntity> query       = new TableQuery <OrdersEntity>();

            string filterquery = TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, queue.RowKey);

            query = new TableQuery <OrdersEntity>().Where(filterquery);

            CloudTable table = tableClient.GetTableReference("orders");
            var        pocos = table.ExecuteQuery(query);


            // Create a table client for interacting with the table service

            Parallel.ForEach(pocos,
                             async x =>
            {
                string subject = "OrderID:" + x.RowKey;
                string message = $"Order with quantity {x.Quantity} and total price {x.Cost}";
                await OmsEmail.SentEmail(x.CustomerEmail, subject, message);
            }
                             );

            log.LogInformation($"C# Queue trigger function processed: {pocos}");
        }
Пример #2
0
        public static void Run([QueueTrigger("orders", Connection = "<Storageconnectionstring>")] QueueItem input,
                               [Table("orders", "{input.PartitionKey}", "{input.RowKey}", Connection = "<Storageconnectionstring>")]
                               IQueryable <OrdersEntity> pocos, ILogger log)
        {
            Parallel.ForEach(pocos,
                             async x =>
            {
                string subject = "OrderID:" + x.RowKey;
                string message = $"Order with quantity {x.Quantity} and total price {x.Cost}";
                await OmsEmail.SentEmail(x.CustomerEmail, subject, message);
            }
                             );

            log.LogInformation($"C# Queue trigger function processed: {pocos}");
        }