I have an Azure Function(V3) and I want to set a customer HTTP rout. I ended up with something like this:
[FunctionName(nameof(GetSomething))]
public async Task<IActionResult> GetSomething(
[HttpTrigger(AuthorizationLevel.Function, "get",
Route = "api/v1/a/b/{bName}/{locationList}?name={name?}&fromDate={fromDate?}&toDate={toDate?}")] HttpRequest req, ILogger log,
string bName, string locationList, string name, string fromDate, string toDate)
{
//body
}
I want to make those values after the {locationList}
optional and give more flexibility for using that URL. However, the rout is not acceptable by the WebJob and the reason is the question mark '?' after {locationList}
"api/v1/a/b/{bName}/{locationList}?name={name?}&fromDate={fromDate?}&toDate={toDate?}"
I found a similar question here. I am not following the answer. Does anyone have a better solution or at least an example of this part
If it's the reason why you want to put query parameter in route, I would suggest you add IDictionary query in method signature and use query["manufacturer"] to access the parameter in function code. But honestly it's almost the same as request.Query["manufacturer"].