public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", "get", Route = null)] HttpRequest req,
            [Table("PRDetail")] CloudTable cloudTable,
            ILogger log)
        {
            PRDetail record                  = new PRDetail();
            dynamic  data                    = JObject.Parse(await new StreamReader(req.Body).ReadToEndAsync());
            string   prefix                  = data.prefix;
            string   prid                    = data.prid;
            string   token                   = data.token;
            string   hashToken               = HashToken(token);
            string   realHashToken           = "";
            TableQuery <PRDetail> rangeQuery = new TableQuery <PRDetail>().Where(
                TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, prefix),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, prid))
                );

            foreach (PRDetail item in await cloudTable.ExecuteQuerySegmentedAsync(rangeQuery, null))
            {
                realHashToken = item.HashedToken;
            }

            if (realHashToken == hashToken)
            {
                return(new OkResult());
            }
            else
            {
                return(new NotFoundResult());
            }
        }
        public static IActionResult Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post")] ValidatePRInfoRequest req,
            [Table("PRDetail", "{groupId}", "{pullRequestId}")] PRDetail match,
            ILogger log)
        {
            log.LogInformation("ValidatePRInfo HTTP trigger function processed a request.");

            string clientId = Environment.GetEnvironmentVariable("JiraClientId", EnvironmentVariableTarget.Process);

            if (string.IsNullOrWhiteSpace(clientId))
            {
                throw new Exception("JiraClientId missing from configuration");
            }

            string clientSecret = Environment.GetEnvironmentVariable("JiraClientSecret", EnvironmentVariableTarget.Process);

            if (string.IsNullOrWhiteSpace(clientSecret))
            {
                throw new Exception("JiraClientSecret missing from configuration");
            }

            if (match == null)
            {
                return(new NotFoundResult());
            }

            if (string.IsNullOrWhiteSpace(req.token) || Utilities.GetHashedToken(req.token) != match.HashedToken)
            {
                return(new UnauthorizedResult());
            }

            var res = new ValidatePRInfoResponse
            {
                clientId     = clientId,
                clientSecret = clientSecret,
                url          = Environment.GetEnvironmentVariable("baseURL", EnvironmentVariableTarget.Process)
            };

            return(new OkObjectResult(res));
        }