Azure Function Optional Query Parameter

Viewed 1678

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
        )
1 Answers

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.
            }
Related