public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get",
                                                                        Route = "CustomerSearch")] HttpRequestMessage req, ILogger log,
                                                           [Inject] IResourceHelper resourceHelper,
                                                           [Inject] IHttpRequestMessageHelper httpRequestMessageHelper,
                                                           [Inject] ISearchCustomerHttpTriggerService searchCustomerService)
        {
            var touchpointId = httpRequestMessageHelper.GetTouchpointId(req);

            if (string.IsNullOrEmpty(touchpointId))
            {
                log.LogInformation("Unable to locate 'APIM-TouchpointId' in request header");
                return(HttpResponseMessageHelper.BadRequest());
            }

            log.LogInformation("C# HTTP trigger function GetCustomerById processed a request. By Touchpoint " + touchpointId);

            SearchHelper.GetSearchServiceClient();
            var indexClient = SearchHelper.GetIndexClient();

            var query  = string.Empty;
            var filter = string.Empty;

            // Parse query parameter
            var givenName  = httpRequestMessageHelper.GetQueryNameValuePairs(req, "GivenName");
            var familyName = httpRequestMessageHelper.GetQueryNameValuePairs(req, "FamilyName");

            if (givenName != null && givenName.Length < 3)
            {
                log.LogWarning("Given Name must have a minimum of 3 characters");
                return(HttpResponseMessageHelper.NoContent());
            }

            if (!string.IsNullOrEmpty(givenName))
            {
                query += string.Format("GivenName:({0}* OR {0}) ", givenName.Trim());
            }

            if (familyName != null && familyName.Length < 3)
            {
                log.LogWarning("Family Name must have a minimum of 3 characters");
                return(HttpResponseMessageHelper.NoContent());
            }

            if (!string.IsNullOrEmpty(familyName))
            {
                query += string.Format("FamilyName:({0}* OR {0}) ", familyName.Trim());
            }

            var uniqueLearnerNumber = httpRequestMessageHelper.GetQueryNameValuePairs(req, "UniqueLearnerNumber");

            if (!string.IsNullOrEmpty(uniqueLearnerNumber))
            {
                query += string.Format("UniqueLearnerNumber:{0}", uniqueLearnerNumber.Trim());
            }

            var dob = httpRequestMessageHelper.GetQueryNameValuePairs(req, "DateofBirth");

            if (!string.IsNullOrEmpty(dob))
            {
                if (DateTime.TryParse(dob.Trim(), CultureInfo.CurrentCulture, DateTimeStyles.None, out var dateOfBirth))
                {
                    filter = string.Format("DateofBirth eq {0:yyyy-MM-dd}", dateOfBirth);
                }
                else
                {
                    return(HttpResponseMessageHelper.NoContent());
                }
            }

            if (string.IsNullOrWhiteSpace(query) && string.IsNullOrWhiteSpace(filter))
            {
                return(HttpResponseMessageHelper.NoContent());
            }

            log.LogInformation("Attempting to search customers");

            var customer = await searchCustomerService.SearchCustomerAsync(indexClient, query, filter);

            log.LogInformation("Search completed");

            return(customer == null?
                   HttpResponseMessageHelper.NoContent() :
                       HttpResponseMessageHelper.Ok(JsonHelper.SerializeObjects(customer)));
        }