Azure functions 如何在Azure函数中使用多个可选参数

Azure functions 如何在Azure函数中使用多个可选参数,azure-functions,asp.net-core-webapi,azure-function-async,Azure Functions,Asp.net Core Webapi,Azure Function Async,如何在Azure函数中使用多个可选参数? 我正在用一个参数创建Azure函数,它正在工作 public async Task<IActionResult> GetRName( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "CommonResource/{subscriptionId?}")] HttpRequest req, string

如何在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"];
请查看附件中的屏幕截图以供参考


您需要更改路由属性

Route = "CommonResource/{subscriptionId:int}/{resourcetype}")
如果要使用多个可选参数,则只能使用连续参数

Route = "CommonResource/{subscriptionId:int?}/{resourcetype?}")
“DefaultInlineConstraintResolver”类型的约束解析程序无法解析路由“api/CommonResource/{subscriptionId:string?}/{resourcetype?}”上的约束项“subscriptionId”-“string”

您正在使用不受支持的{subscriptionId:string?},这会导致上述错误

列出了支持的约束,请参考


您想使用什么参数?我想使用resourcetype和location。有可能吗?当我添加这个代码Route=CommonResource/{subscriptionId:int?}/{resourcetype?}时,我遇到了一个错误