c# - 如何使用 Rest API 在 azure 表中使用延续 token

标签 c# rest azure-storage

我正在使用 .net Azure 存储客户端库从服务器检索数据。

我的实体包含超过 10000 条记录 & 它正在一次检索 1000 条记录 & 给出响应标题 x-ms-continuation-NextPartitionKey & x-ms-continuation-NextRowKey

我提到了这个

https://learn.microsoft.com/en-us/rest/api/storageservices/Query-Entities?redirectedfrom=MSDN]

但不明白下次如何使用这些 header 使用 Rest API 获取连续记录

string storageAccount = "MyAccount";
string accessKey = "MYAccessKey";
string TableName = "TableName";
string uri = @"https://" + storageAccount + ".table.core.windows.net/" + TableName  + "?$top=100";
// Web request 
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = "GET";
request.ContentType = "application/json";
request.Accept = "application/json;odata=nometadata";
request.Headers["x-ms-date"] = DateTime.UtcNow.ToString("R", System.Globalization.CultureInfo.InvariantCulture);
request.Headers["x-ms-version"] = "2015-04-05";           
string stringToSign = request.Headers["x-ms-date"] + "\n";    
stringToSign += "/" + storageAccount + "/" + TableName;
System.Security.Cryptography.HMACSHA256 hasher = new System.Security.Cryptography.HMACSHA256(Convert.FromBase64String(accessKey));
string strAuthorization = "SharedKeyLite " + storageAccount + ":" + System.Convert.ToBase64String(hasher.ComputeHash(System.Text.Encoding.UTF8.GetBytes(stringToSign)));


request.Headers["Authorization"] = strAuthorization;

Task<WebResponse> response = request.GetResponseAsync();
HttpWebResponse responseresult = (HttpWebResponse)response.Result;

最佳答案

如果您想继续查询,使用原始查询,但将参数添加到请求 - 而不是 header ,以查询:

http://account.table....?query...&NextPartitionKey={value from x-ms-continuation-NextPartitionKey response header}&NextRowKey={value from x-ms-continuation-NextRowKey response header}

关于c# - 如何使用 Rest API 在 azure 表中使用延续 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47547124/

相关文章:

c# - 如何将 LoggerFactory 的实例传递给 ActionFilterAttribute

java - 使用 Java(特别是 Android)发布到 REST api

具有表存储的 Azure 移动 Web 服务

azure - 批量查询异步复制 Blob Azure API 的状态

c++ - Firebase 匿名 rest 身份验证

Azure Blob 容器

c# - 如何在两个 Activity 之间传递变量?

c# - 根据文件名运行正确的方法 (C#)

c# - 将测试项目 appSettings 附加到 ASP.NET Core 集成测试

java - 使用 Volley 与 ESP8266 与 AndroidApp 通信