Is there a way to map empty string as route to an Azure Function. Like lets say when I hit the https://example.org/api (empty string), the function will be hit. I have tried like below, but it did not work.
[FunctionName("Default")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "")] HttpRequest req,
ILogger log)
{
...
}
Turns out there is no direct way to do it. PFB the screenshot with the error message picked from the console after running Functions solution.
However, it can be achieved using Function proxy. Add the below json to your proxies.json. So, this way lets say you are hitting "http://localhost:7071/api/" it will land on your specified function.
{
"proxies": {
"EmptyRouteProxy": {
"matchCondition": {
"route": "/"
},
"backendUri": "http://localhost:7071/api/SampleFunc"
}
}
}