'Azure Function Optional Query Parameter
is there a way to set optional query parameters in Azure Functions? The parameter should not be set as route parameter. To get the query parameters i use following code snipped
IDictionary<string, string> queryParams = req.GetQueryParameterDictionary();
Methode signature is following:
public async Task<IActionResult> Function(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
[DurableClient] IDurableOrchestrationClient starter
)
Solution 1:[1]
If you don't want to set it as the route parameter, you can use like below:
string param = req.Query["param"];
if (string.IsNullOrEmpty(param)) {
//do nothing.
} else {
//do something.
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | halfer |