[英]Azure Cosmos DB - StartIndex cannot be less than zero. (Parameter 'startIndex')
[英]How to specify the route Groups?startIndex={startIndex}&count={count} for azure functions
如何以以下格式指定 azure function 的路由
Groups?startIndex={startIndex}&count={count}
由於Microsoft Q&A中已經討論過相同的問題,感謝Mayank Bargali - 發布您的答案以幫助其他社區成員:
您只能定義
string
值,因為 Route 屬性是字符串類型。 根據您的要求,您可以如下定義路由並獲取查詢參數,您可以利用HttpRequest
objectQuery
參數。 有關路由參數和查詢字符串的更多詳細信息,請參閱此文檔。Route = "tc2/users/Groups/{id:int?}"
我使用以下 C# 代碼進行測試。
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "tc2/users/Groups/{id:int?}")] HttpRequest req, int? id,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
int startIndex, count;
if (.String.IsNullOrEmpty(req.Query["startIndex"]))
startIndex = int.Parse(req.Query["startIndex"]);
if (.String.IsNullOrEmpty(req.Query["count"]))
count = int.Parse(req.Query["count"]);
return new OkObjectResult("Ok");
}
注:以上內容僅供參考,請根據業務需要進行更新,並在轉換查詢參數時處理異常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.