gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 14:58:34 24 4
gpt4 key购买 nike

我正在使用 .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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com