我正在使用 PWSH 7 / REST API 來查詢包含超過 1000 個條目的表,我可以使用以下代碼很好地查詢它:
$RGName = "MyResourceGroup"
$StorageAccount = "MyStorageAccount"
$TableName = "MyTable"
$SA = Get-AzStorageAccount -Name $StorageAccount -ResourceGroupName $RGName -verbose
$Accesskey = ($SA | Get-AzStorageAccountKey).value[0]
$Version = "2021-08-06"
$Table_url = "https://$StorageAccount.table.core.windows.net/$TableName"
$GMTTime = (Get-Date).ToUniversalTime().toString('R')
$stringToSign = "$GMTTime`n/$StorageAccount/$TableName"
$HMACSHA = New-Object System.Security.Cryptography.HMACSHA256
$HMACSHA.key = [Convert]::FromBase64String($Accesskey)
$Signature = $HMACSHA.ComputeHash([Text.Encoding]::UTF8.GetBytes($stringToSign))
$Signature = [Convert]::ToBase64String($Signature)
$Headers = @{
'x-ms-date' = $GMTTime
Authorization = "SharedKeyLite " $StorageAccount ":" $Signature
"x-ms-version" = $Version
Accept = "application/json;odata=fullmetadata"
}
$Item = Invoke-RestMethod -Method GET -Uri $Table_url -Headers $Headers -ContentType application/json
但是,我沒有得到回傳的延續標記,所以我看不到獲取表中下一個條目的方法。根據這個檔案,看起來我應該得到一個。
誰能告訴我我做錯了什么?
uj5u.com熱心網友回復:
如果您查看 ,會在回應標頭中回傳documentation延續標記 (x-ms-continuation-NextPartitionKey和)。x-ms-continuation-NextRowKey
要在 Cmdlet 中獲取回應標頭Invoke-RestMethod,您需要指定-ResponseHeadersVariable變數,然后您應該能夠獲取這些回應標頭。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/533626.html
