public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "report/tokens")] HttpRequest req, [Table("tokens")] CloudTable tokenTable, ILogger log) { var continuationToken = default(TableContinuationToken); try { continuationToken = PagedEntities <TokenEntity> .GetContinuationToken(req); } catch (Exception exc) { log.LogError($"Failed to deserialize continuation token", exc); return(new BadRequestResult()); } var segment = await tokenTable.ExecuteQuerySegmentedAsync <TokenEntity>(new TableQuery <TokenEntity>(), continuationToken).ConfigureAwait(false); var result = new PagedEntities <TokenEntity>(segment) { NextLink = (segment.ContinuationToken != null ? PagedEntities <TokenEntity> .GetNextLink(req, segment.ContinuationToken) : null) }; return(new OkObjectResult(result)); }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "report/users")] HttpRequestMessage req, [Table("users")] CloudTable userTable, TraceWriter log) { var continuationToken = default(TableContinuationToken); try { continuationToken = PagedEntities <UserEntity> .GetContinuationToken(req); } catch (Exception exc) { log.Error($"Failed to deserialize continuation token", exc); return(req.CreateResponse(HttpStatusCode.BadRequest)); } var segment = await userTable.ExecuteQuerySegmentedAsync <UserEntity>(new TableQuery <UserEntity>(), continuationToken).ConfigureAwait(false); var result = new PagedEntities <UserEntity>(segment) { NextLink = (segment.ContinuationToken != null ? PagedEntities <UserEntity> .GetNextLink(req, segment.ContinuationToken) : null) }; return(req.CreateResponse(HttpStatusCode.OK, result, "application/json")); }