How to specify a query parameter in a custom HTTP route of an Azure Function?
I am afraid it's not possible to put query parameter in Route.
Microsoft.AspNetCore.Routing: The literal section 'products?manufacturer=' is invalid. Literal sections cannot contain the '?' character.
It's a built-in restriction of ASP.NET Routing, which is used by Azure Function to build route for Http trigger.
allow me to get the value as one of the Run's method parameters instead of poking at the HttpRequest instance
If it's the reason why you want to put query parameter in route, I would suggest you add IDictionary<string, string> 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"]
.
Or you may have to follow the recommendation, transform the query parameter to route like products/{productId}
.