我正在运行一个查询 CosmosDB 实例的 Azure 函数。
我正在尝试使用延续令牌实现分页,但在使用延续令牌调用我的函数时,我不断收到以下响应:
Message": "发生错误。", "ExceptionMessage": "Invalid Continuation Token\r\nActivityId: 0f79a65f-a9d2-49a8-8a9c-d33a8526bec8, Microsoft.Azure.Documents.Common/2.0.0.0, documentdb-dotnet- sdk/1.22.0 主机/32-bit MicrosoftWindowsNT/6.2.9200.0
这是我的 Azure 函数:该函数最初将在没有令牌的情况下调用,并且根据第二页的请求,将传入令牌。
[FunctionName("GetAllPaged")]
public static async Task<HttpResponseMessage> ReadAll(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "GetAllPaged/{pageSize?}/{token?}")]HttpRequestMessage req,
int? pageSize, string token, ILogger log, [Inject]IComponent<EventModel> component)
{
try
{
log.LogInformation("Get all events");
var response = await component.GetAll_Paged(pageSize, token);
return req.CreateResponse(HttpStatusCode.OK, response);
}
catch (Exception ex)
{
log.LogError(ex.Message, ex);
return req.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
}
}
在我最初调用我的 Azure 函数时,使用 URL http://localhost:7071/api/Event/GetAllPaged/3,我得到以下响应:
{
"Continuation": {
"token": "CDhbANnikwAGAAAAAAAAAA==",
"range": {
"min": "",
"max": "FF"
}
},
"Results": [
{
"id": "c428e1c4-48d5-47ae-9f37-c29cc3fc8696",
"Description": "Test description nr: 64791",
"User": "Test User"
},
{
"id": "bab08fe7-da5c-48c6-971d-a14ef3eb5f4c",
"Description": "Test description nr: 63486",
"User": "Test User"
},
{
"id": "9688acc2-4acf-4acd-a252-5481b5b4d450",
"Description": "Test description nr: 86498",
"User": "Test User"
}
]
}
当我使用下一个 Azure 函数请求中提供的令牌时,使用带有令牌http://localhost:7071/api/Event/GetAllPaged/3/CDhbANnikwAGAAAAAAAAAA==的 url ,我收到上面列出的错误。
我究竟做错了什么?