I am using Powershell to read data from an Azure Storage Table. I want to use the API directly without any modules.
I use a SAS token for authentication.
$SASToken = '?sv=2022-11-02&ss=bfqt&srt=s&sp=rwdlacupiytfx&se=2023-12-27T09:28:48Z&st=2023-12-27T01:28:48Z&spr=https&sig=2gqxxxxxx'
$GMTTime = (Get-Date).ToUniversalTime().toString('R')
$headers = @{
'x-ms-date' = $GMTTime;
Accept = 'application/json;odata=nometadata'
}
$url = "https://$StorageAccountName.table.core.windows.net/${TableName}${SASToken}"
$response = Invoke-WebRequest -Uri $url -Headers $headers -Method Get -ErrorAction Stop
$NextRowKey = $response.Headers.'x-ms-continuation-NextRowKey'
$NextPartitionKey = $response.Headers.'x-ms-continuation-NextPartitionKey'
This first call works as expected.
I was reading the documentation and I still cannot figure out how to construct the URL for the next page (1000 entries).
I tried
$url = "http://$StorageAccountName.table.core.windows.net/${TableName}${SASToken}?NextPartitionKey=$NextPartitionKey&NextRowKey=$NextRowKey"
Invoke-WebRequest -Uri $url -Headers $headers -Method Get -ErrorAction Stop
Invoke-WebRequest:
AuthenticationFailed
Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature.
None of the variables are empty and all of them have the correct value.
The above error occurred when you passed the wrong parameter or invalid sas token, also I see in your
urlyou have passed two times?in the script which makes you get an authentication error.Here is the full script, Which worked in my environment.
Script:
Output:
Reference:
Query timeout and pagination (REST API) - Azure Storage | Microsoft Learn