Azure Table: Save and Resume an Entity Query
See more Azure Table Service Examples
Fetches one page per invocation and saves private JSON plus a checkpoint bound to the account, collection path, filter, projection, page size and API version. Refuses to overwrite an unprocessed page. Process/archive qa_output/table-page.json before the next run; keep table-checkpoint.json until completion.
This demonstrates at-least-once processing, not an atomic transaction between output and checkpoint. A crash or failed checkpoint write can replay a page; deduplicate by entity identity/version. A malformed checkpoint stops instead of restarting. Use a single caller, protect files, and use transactional durable state for stronger guarantees. Table contents can change during enumeration.
Targets Azure Storage Table service in the public cloud, not Azure Cosmos DB for Table. Uses Chilkat 11.6.0 or later and an unlocked library. Direct data requests pin x-ms-version 2026-04-06 and OData 3.0. Shared Key examples read private qa_data/azure/storage.json with account and access_key string fields. Authentication examples explain their additional fields. Create private local directories before running; keep credentials, tokens, SAS, entity values, checkpoints and diagnostics outside public content and source control.
HTTPS certificates are verified. Transport completion and HTTP status are checked separately. Writes are not automatically retried after an uncertain outcome. Entity keys, ETags and continuation tokens remain strings. Examples operate on the existing ExampleCustomers table unless noted; review the targets before adapting them. Microsoft Entra ID with suitable Table data roles is preferred where available.
Chilkat AutoIt Downloads
Local $bSuccess = False
; StringBuilder compares text by value in every generated language.
$oTextCompare = ObjCreate("Chilkat.StringBuilder")
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$bSuccess = False
$oConfig = ObjCreate("Chilkat.JsonObject")
$oConfig.Strict = True
$bSuccess = $oConfig.LoadFile("qa_data/azure/storage.json")
If ($bSuccess <> True) Then
ConsoleWrite("Could not load private Azure configuration." & @CRLF)
Exit
EndIf
$oTextCompare.Clear
$oTextCompare.SetString($oConfig.StringOf("account"))
Local $bSameText1 = $oTextCompare.ContentsEqual("",True)
If (($oConfig.JsonTypeOf("account") <> 1) Or ($bSameText1 = True)) Then
ConsoleWrite("Supply the storage account name." & @CRLF)
Exit
EndIf
; access_key is the base64 account key, not a connection string or SAS.
$oTextCompare.Clear
$oTextCompare.SetString($oConfig.StringOf("access_key"))
Local $bSameText2 = $oTextCompare.ContentsEqual("",True)
If (($oConfig.JsonTypeOf("access_key") <> 1) Or ($bSameText2 = True)) Then
ConsoleWrite("Supply the base64 account access key." & @CRLF)
Exit
EndIf
$oAccountText = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oAccountText.Append($oConfig.StringOf("account"))
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
If (($oAccountText.Length < 3) Or ($oAccountText.Length > 24)) Then
ConsoleWrite("Storage account names need 3-24 lowercase letters or digits." & @CRLF)
Exit
EndIf
$oAllowedAccountChars = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oAllowedAccountChars.Append("abcdefghijklmnopqrstuvwxyz0123456789")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
Local $iCharIndex = 0
While ($iCharIndex < $oAccountText.Length)
If ($oAllowedAccountChars.Contains($oAccountText.GetRange($iCharIndex,1,False),True) <> True) Then
ConsoleWrite("Storage account names need lowercase letters or digits." & @CRLF)
Exit
EndIf
$iCharIndex = $iCharIndex + 1
Wend
$oEndpoint = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oEndpoint.Append($oConfig.StringOf("account"))
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oEndpoint.Append(".table.core.windows.net")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
; Table names contain only letters and digits and are case-insensitive.
; Entity PartitionKey and RowKey values are case-sensitive.
Local $sResourcePath = "/ExampleCustomers()"
$oRest = ObjCreate("Chilkat.Rest")
$oRest.ConnectTimeoutMs = 20000
$oRest.IdleTimeoutMs = 60000
$oAzAuth = ObjCreate("Chilkat.AuthAzureStorage")
$oAzAuth.Account = $oConfig.StringOf("account")
$oAzAuth.AccessKey = $oConfig.StringOf("access_key")
$oAzAuth.Service = "Table"
$oAzAuth.Scheme = "SharedKey"
$oAzAuth.XMsVersion = "2026-04-06"
$bSuccess = $oRest.SetAuthAzureStorage($oAzAuth)
If ($bSuccess <> True) Then
ConsoleWrite("Could not configure Shared Key signing." & @CRLF)
Exit
EndIf
$oConnection = ObjCreate("Chilkat.Socket")
$oConnection.RequireSslCertVerify = True
$oConnection.MaxReadIdleMs = 60000
$oConnection.MaxSendIdleMs = 60000
$bSuccess = $oConnection.Connect($oEndpoint.GetAsString(),443,True,20000)
If ($bSuccess <> True) Then
ConsoleWrite("TLS connection failed; inspect diagnostics privately." & @CRLF)
Exit
EndIf
; Do not replay a write automatically after losing its response.
$bSuccess = $oRest.UseConnection($oConnection,False)
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
Local $sResponseText
$oResult = ObjCreate("Chilkat.JsonObject")
$oResult.Strict = True
$bSuccess = $oRest.AddHeader("DataServiceVersion","3.0;NetFx")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oRest.AddHeader("MaxDataServiceVersion","3.0;NetFx")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oRest.AddHeader("Content-Type","application/json")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oRest.AddHeader("Accept","application/json;odata=minimalmetadata")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
; Single-caller, one-page-per-run example. Archive table-page.json before the next run.
$oFiles = ObjCreate("Chilkat.FileAccess")
If ($oFiles.FileExists("qa_output/table-page.json") = True) Then
ConsoleWrite("Previous page output exists; process and archive it before continuing." & @CRLF)
Exit
EndIf
$oCheckpoint = ObjCreate("Chilkat.JsonObject")
$oCheckpoint.Strict = True
Local $sNextPartition = ""
Local $sNextRow = ""
If ($oFiles.FileExists("qa_data/azure/table-checkpoint.json") = True) Then
$bSuccess = $oCheckpoint.LoadFile("qa_data/azure/table-checkpoint.json")
If ($bSuccess <> True) Then
ConsoleWrite("Invalid checkpoint; do not silently restart." & @CRLF)
Exit
EndIf
$oTextCompare.Clear
$oTextCompare.SetString($oCheckpoint.StringOf("path"))
Local $bSameText3 = $oTextCompare.ContentsEqual($sResourcePath,True)
$oTextCompare.Clear
$oTextCompare.SetString($oCheckpoint.StringOf("filter"))
Local $bSameText4 = $oTextCompare.ContentsEqual("PartitionKey eq 'customers-west'",True)
$oTextCompare.Clear
$oTextCompare.SetString($oCheckpoint.StringOf("select"))
Local $bSameText5 = $oTextCompare.ContentsEqual("PartitionKey,RowKey,Address,NumberOfOrders",True)
$oTextCompare.Clear
$oTextCompare.SetString($oCheckpoint.StringOf("top"))
Local $bSameText6 = $oTextCompare.ContentsEqual("100",True)
$oTextCompare.Clear
$oTextCompare.SetString($oCheckpoint.StringOf("version"))
Local $bSameText7 = $oTextCompare.ContentsEqual("2026-04-06",True)
If (($oCheckpoint.StringOf("account") <> $oConfig.StringOf("account")) Or ($bSameText3 <> True) Or ($bSameText4 <> True) Or ($bSameText5 <> True) Or ($bSameText6 <> True) Or ($bSameText7 <> True)) Then
ConsoleWrite("Checkpoint belongs to a different account or query." & @CRLF)
Exit
EndIf
If (($oCheckpoint.JsonTypeOf("complete") <> 5) Or ($oCheckpoint.JsonTypeOf("partition") <> 1) Or ($oCheckpoint.JsonTypeOf("row") <> 1)) Then
ConsoleWrite("Checkpoint fields are invalid." & @CRLF)
Exit
EndIf
If ($oCheckpoint.BoolOf("complete") = True) Then
ConsoleWrite("Query already complete." & @CRLF)
Exit
EndIf
$sNextPartition = $oCheckpoint.StringOf("partition")
$sNextRow = $oCheckpoint.StringOf("row")
$oTextCompare.Clear
$oTextCompare.SetString($sNextPartition)
Local $bSameText8 = $oTextCompare.ContentsEqual("",True)
If ($bSameText8 = True) Then
ConsoleWrite("Incomplete checkpoint has no continuation token." & @CRLF)
Exit
EndIf
EndIf
$bSuccess = $oRest.AddQueryParam("$filter","PartitionKey eq 'customers-west'")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oRest.AddQueryParam("$select","PartitionKey,RowKey,Address,NumberOfOrders")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oRest.AddQueryParam("$top","100")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$oTextCompare.Clear
$oTextCompare.SetString($sNextPartition)
Local $bSameText9 = $oTextCompare.ContentsEqual("",True)
If ($bSameText9 <> True) Then
$bSuccess = $oRest.AddQueryParam("NextPartitionKey",$sNextPartition)
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
EndIf
$oTextCompare.Clear
$oTextCompare.SetString($sNextRow)
Local $bSameText10 = $oTextCompare.ContentsEqual("",True)
If ($bSameText10 <> True) Then
$bSuccess = $oRest.AddQueryParam("NextRowKey",$sNextRow)
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
EndIf
$sResponseText = $oRest.FullRequestNoBody("GET",$sResourcePath)
If ($oRest.LastMethodSuccess <> True) Then
ConsoleWrite("Request did not complete; inspect the target before retrying a write." & @CRLF)
Exit
EndIf
If ($oRest.ResponseStatusCode <> 200) Then
ConsoleWrite("HTTP status: " & $oRest.ResponseStatusCode & @CRLF)
ConsoleWrite("Request ID: " & $oRest.ResponseHdrByName("x-ms-request-id") & @CRLF)
; 404 is missing, 409 is conflict, and 412 is a stale ETag: none are success.
; Keep response bodies private. Reconcile uncertain writes before retrying.
Exit
EndIf
$bSuccess = $oResult.Load($sResponseText)
If ($bSuccess <> True) Then
ConsoleWrite("Expected well-formed JSON." & @CRLF)
Exit
EndIf
If ($oResult.JsonTypeOf("value") <> 4) Then
ConsoleWrite("Missing entity/table array." & @CRLF)
Exit
EndIf
Local $sFollowingPartition = $oRest.ResponseHdrByName("x-ms-continuation-NextPartitionKey")
Local $sFollowingRow = $oRest.ResponseHdrByName("x-ms-continuation-NextRowKey")
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingPartition)
Local $bSameText11 = $oTextCompare.ContentsEqual("null",True)
If ($bSameText11 = True) Then
$sFollowingPartition = ""
EndIf
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingRow)
Local $bSameText12 = $oTextCompare.ContentsEqual("null",True)
If ($bSameText12 = True) Then
$sFollowingRow = ""
EndIf
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingPartition)
Local $bSameText13 = $oTextCompare.ContentsEqual("",True)
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingRow)
Local $bSameText14 = $oTextCompare.ContentsEqual("",True)
If (($bSameText13 = True) And ($bSameText14 <> True)) Then
ConsoleWrite("Malformed continuation." & @CRLF)
Exit
EndIf
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingPartition)
Local $bSameText15 = $oTextCompare.ContentsEqual("",True)
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingPartition)
Local $bSameText16 = $oTextCompare.ContentsEqual($sNextPartition,True)
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingRow)
Local $bSameText17 = $oTextCompare.ContentsEqual($sNextRow,True)
If (($bSameText15 <> True) And ($bSameText16 = True) And ($bSameText17 = True)) Then
ConsoleWrite("Service repeated the current checkpoint." & @CRLF)
Exit
EndIf
; Save the page before advancing its checkpoint. Failures can cause replay, never intentional skipping.
$bSuccess = $oResult.WriteFile("qa_output/table-page.json")
If ($bSuccess <> True) Then
ConsoleWrite("Could not save private page output." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("account",$oConfig.StringOf("account"))
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("path",$sResourcePath)
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("filter","PartitionKey eq 'customers-west'")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("select","PartitionKey,RowKey,Address,NumberOfOrders")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("top","100")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("version","2026-04-06")
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("partition",$sFollowingPartition)
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.UpdateString("row",$sFollowingRow)
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
Local $bCompleted = False
$oTextCompare.Clear
$oTextCompare.SetString($sFollowingPartition)
Local $bSameText18 = $oTextCompare.ContentsEqual("",True)
If ($bSameText18 = True) Then
$bCompleted = True
EndIf
$bSuccess = $oCheckpoint.UpdateBool("complete",$bCompleted)
If ($bSuccess <> True) Then
ConsoleWrite("Could not prepare the request." & @CRLF)
Exit
EndIf
$bSuccess = $oCheckpoint.WriteFile("qa_data/azure/table-checkpoint.json")
If ($bSuccess <> True) Then
ConsoleWrite("Page saved but checkpoint write failed. Preserve the page and reconcile before resuming." & @CRLF)
Exit
EndIf
ConsoleWrite("Page and continuation checkpoint saved privately." & @CRLF)