如何在 Azure 函数中使用多个可选参数?我正在使用一个参数创建这样的 Azure 函数,它正在工作。
public async Task<IActionResult> GetRName(
[HttpTrigger(AuthorizationLevel.Function, "get",
Route = "CommonResource/{subscriptionId?}")] HttpRequest req,
string subscriptionId,
string resourcetype,
string location,
ILogger log)
{
---
}
如果我添加这样的附加参数,则会出现错误。
[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"];
请检查随附的屏幕截图以供参考。