public async Task Run(
            Microsoft.Azure.WebJobs.ExecutionContext context,
            [ServiceBusTrigger("sbq-queueflow", Connection = "ServiceBusConnection")] string myQueueItem,
            ILogger logger)
        {
            await dotnetcore.azFunction.AppShim.Global.InitializeShimAsync(context, _functionsAppShim, logger);

            var job  = _serializer.Deserialize <Job>(myQueueItem);
            var json = _serializer.Serialize(job);

            logger.LogInformation($"C# ServiceBus queue trigger function processed message: {json}");


            var httpRequestMessage = new HttpRequestMessage(
                HttpMethod.Post,
                "http://localhost/api/MyServiceBusTriggerFunction")
            {
                Content = new StringContent(
                    json,
                    Encoding.UTF8, "application/json")
            };


            var response = await _functionsAppShim.SendAsync(context, httpRequestMessage);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Run(
            Microsoft.Azure.WebJobs.ExecutionContext context,
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "Crud")] HttpRequest req,
            ILogger logger)
        {
            if (!Globals.Initialized)
            {
                await _functionsAppShim.Initialize(logger);

                Globals.Initialized = true;
            }

            logger.LogInformation("C# HTTP trigger function processed a request.");
            var job = new Job
            {
                Id         = Guid.NewGuid().ToString(),
                IssuedTime = DateTime.UtcNow,
                Name       = "My SuperDuper Job"
            };
            var json = _serializer.Serialize(job);

            logger.LogInformation($"C# ServiceBus queue trigger function processed message: {json}");


            var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/MyCrud")
            {
                Content = new StringContent(
                    json,
                    Encoding.UTF8, "application/json")
            };


            var response = await _functionsAppShim.SendAsync(context, httpRequestMessage);

            return(new OkObjectResult(job));
        }