如何使用Rest API在azure表中使用延续令牌 [英] How to use continuation tokens in azure table Using Rest API
问题描述
我使用.net Azure存储客户端库从服务器检索数据.
Iam using .net Azure storage client library to retrieve data from server.
我的实体"包含10000多个记录&一次检索1000条记录&给响应标头x-ms-continuation-NextPartitionKey& x-ms-continuation-NextRowKey
My Entity contains more than 10000 records & it is retrieving 1000 records at once & giving response Headers x-ms-continuation-NextPartitionKey & x-ms-continuation-NextRowKey
我提到了
https://docs. microsoft.com/en-us/rest/api/storageservices/Query-Entities?redirectedfrom=MSDN]
但是不知道下次如何使用这些标头使用Rest API来获取连续记录
But did not understand how to use the those headers next time to get continuous records using 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;
推荐答案
如果要继续查询,请使用原始查询,但要添加参数以请求-而不是标题,以进行查询:
If you want to continue in query, use original query, but add parameters to request - not to headers, to query:
http://account.table....?query...&NextPartitionKey={value from x-ms-continuation-NextPartitionKey response header}&NextRowKey={value from x-ms-continuation-NextRowKey response header}
这篇关于如何使用Rest API在azure表中使用延续令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!