public static async Task <LoanApplication> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
            HttpRequestMessage req,
            //[Queue("loan-applications")] out string message,
            [Queue("loan-applications")] IAsyncCollector <LoanApplication> messageQueue,
            TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            LoanApplication application = await req.Content.ReadAsAsync <LoanApplication>();

            log.Info($"Application received: {application.Name} {application.Age}");

            // TODO: write to queue
            //await messageQueue.AddAsync(application);
            return(application);

            //return req.CreateResponse(HttpStatusCode.OK,
            //                          $"Loan application submitted for {application.Name}");
        }
Beispiel #2
0
        public static void Run([QueueTrigger("loan-applications", Connection = "")]
                               LoanApplication application,
                               [Blob("accepted-applications/{rand-guid}", Connection = "")] out string acceptedApplication,
                               [Blob("declined-applications/{rand-guid}", Connection = "")] out string declinedApplication,
                               TraceWriter log)
        {
            log.Info($"C# Queue trigger function processed: {application.Name}");

            var isAccepted = application.Age >= 18;

            if (isAccepted)
            {
                acceptedApplication = JsonConvert.SerializeObject(application);
                declinedApplication = null;
            }
            else
            {
                acceptedApplication = null;
                declinedApplication = JsonConvert.SerializeObject(application);
            }
        }