Ejemplo n.º 1
0
 private static async Task PostFunctionResultToPlayFab(ScheduledTaskFunctionExecutionContext ctx, object result, long executionTime, ILogger log)
 {
     if (ctx.GeneratePlayStreamEvent.HasValue && ctx.GeneratePlayStreamEvent.Value)
     {
         await HelperFunctions.PostResults(ctx, nameof(IdentityQueuedTask), result, (int)executionTime, log);
     }
 }
        public static async Task <object> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] ScheduledTaskFunctionExecutionContext req,
            HttpRequest httpRequest,
            ILogger log)
        {
            string body = await httpRequest.ReadAsStringAsync();

            log.LogInformation($"HTTP POST Body: {body}");

            return(await Task.FromResult(req.FunctionArgument));
        }
Ejemplo n.º 3
0
        public static async Task <object> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest httpRequest,
            ILogger log)
        {
            string body = await httpRequest.ReadAsStringAsync();

            log.LogInformation($"HTTP POST Body: {body}");

            ScheduledTaskFunctionExecutionContext <object[]> req = JsonConvert.DeserializeObject <ScheduledTaskFunctionExecutionContext <object[]> >(body);

            log.LogInformation($"ScheduledTaskFunctionExecutionContext: {JsonConvert.SerializeObject(req)}");

            return(await Task.FromResult(req.FunctionArgument));
        }
Ejemplo n.º 4
0
        public static async Task Run(
            [QueueTrigger("identitytask", Connection = "AzureWebJobsStorage")] string msg,
            ILogger log)
        {
            Stopwatch sw = Stopwatch.StartNew();

            log.LogInformation($"{nameof(IdentityQueuedTask)} C# queue trigger function processed a request; {msg}");

            ScheduledTaskFunctionExecutionContext ctx = JsonConvert.DeserializeObject <ScheduledTaskFunctionExecutionContext>(msg);

            // Simulate work
            await Task.Delay(IdentityQueuedTask.delayMilliseconds);

            // Post results
            await PostFunctionResultToPlayFab(ctx, ctx.FunctionArgument, sw.ElapsedMilliseconds, log);
        }
        public static Task PostResults(ScheduledTaskFunctionExecutionContext ctx, string functionName, object functionResult, int executionTime, ILogger log)
        {
            var request = new PostFunctionResultForScheduledTaskRequest
            {
                Entity = new EntityKey
                {
                    Id   = ctx.TitleAuthenticationContext.Id,
                    Type = "title"
                },
                ScheduledTaskId = ctx.ScheduledTaskNameId,
                FunctionResult  = new ExecuteFunctionResult
                {
                    ExecutionTimeMilliseconds = executionTime,
                    Error          = null,
                    FunctionName   = functionName,
                    FunctionResult = functionResult
                }
            };

            // TODO: Replace this code with an SDK call once an SDK is published that supports PostFunctionResultForScheduledTask
            return(CallPostResultApi("PostFunctionResultForScheduledTask", ctx.TitleAuthenticationContext, request, log));
        }