Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
        )
like image 269
korates Avatar asked Sep 15 '26 16:09

korates


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.
            }
like image 63
Cindy Pau Avatar answered Sep 18 '26 11:09

Cindy Pau