Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use continuation tokens in azure table Using Rest API

Iam using .net Azure storage client library to retrieve data from server.

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

I referred this

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

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;
like image 534
champ Avatar asked Oct 23 '25 05:10

champ


1 Answers

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}
like image 164
Michal Dobrodenka Avatar answered Oct 25 '25 20:10

Michal Dobrodenka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!