How to use multiple optional parameter in Azure function? I am creating Azure function like this with one parameter, it is working.
public async Task<IActionResult> GetRName(
[HttpTrigger(AuthorizationLevel.Function, "get",
Route = "CommonResource/{subscriptionId?}")] HttpRequest req,
string subscriptionId,
string resourcetype,
string location,
ILogger log)
{
---
}
If i add additional parameter like this getting an error.
[FunctionName("GetResourceName")]
public async Task<IActionResult> GetRName(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "CommonResource/{subscriptionId:string?}/{resourcetype?}")] HttpRequest req,
string subscriptionId ,string resourcetype , ILogger log)
{
log.LogInformation("This API should return Resource name.");
//string resourcetype = req.Query["resourcetype"];
resourcetype = req.Query["resourcetype"];
string location = req.Query["location"];
Please check the attached screen shot for your referance.
You need to change you Route property
If you want to use multiple optional parameters, only consecutive parameters will work