public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "Program/v2/List/{maxItems}")] HttpRequest req, string maxItems,
            ILogger log)
        {
            int items;

            // Check if the maxItems parameter is an int
            if (int.TryParse(maxItems, out items))
            {
                // Set sensible default value
                if (items < 0)
                {
                    items = 1;
                }

                var jsonString = await VodProgramList.GetProgramList(items);

                if (jsonString != null)
                {
                    // return ProgramList
                    log.LogInformation("Executed GetProgramList({0}) - Size: {1}", items, jsonString.Length);
                    return(new OkObjectResult(jsonString));
                }
                else
                {
                    // No content - this should not really happen!
                    log.LogError("No content returned for GetProgramList({0})", items);
                    return(new NoContentResult());
                }
            }
            else
            {
                // Invalid maxItems parameter
                log.LogError("Invalid maxItems parameter provided for GetProgramList: {0}", maxItems);
                return(new BadRequestResult());
            }
        }
Exemplo n.º 2
0
 public static async void Run([TimerTrigger("0 0 */2 * * *")] TimerInfo myTimer, ILogger log)
 {
     var success = await VodProgramList.PopulateCloudCache(log);
 }