コード例 #1
0
        public static async Task <object> Run(
            // [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]  ScheduledTaskFunctionExecutionContext req,
            // HttpRequest httpRequest,
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]  HttpRequest httpRequest,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            log.LogInformation($"Settings.TitleSecret: {Settings.TitleSecret}");

            string body = await httpRequest.ReadAsStringAsync();

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

            ScheduledTaskFunctionExecutionContext <object> ctx = JsonConvert.DeserializeObject <ScheduledTaskFunctionExecutionContext <object> >(body);

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


            return(await Task.FromResult(ctx.FunctionArgument));
        }
コード例 #2
0
        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));
        }