Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.6.0+

Azure Table: Retry a Read with Bounded Backoff

See more Azure Table Service Examples

Retries only this GET for selected transient HTTP statuses, at most five attempts. Uses exponential backoff plus jitter and honors numeric or HTTP-date Retry-After without shortening a requested wait. Stops when the server asks for more than 30 seconds, on invalid Retry-After, authentication failures or transport errors. Each connection/read also has a timeout. This is not a generic write-retry policy; uncertain mutation outcomes require reconciliation.

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.

Microsoft reference.

Chilkat AutoIt Downloads

AutoIt
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

Local $sPartitionKey = "customers-west"
Local $sRowKey = "customer-001"
$oEncodedPk = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oEncodedPk.Append($sPartitionKey)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

Local $iEscapedencodedPk = $oEncodedPk.Replace("'","''")
$bSuccess = $oEncodedPk.Encode("url_rfc3986","utf-8")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$oEncodedRk = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oEncodedRk.Append($sRowKey)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

Local $iEscapedencodedRk = $oEncodedRk.Replace("'","''")
$bSuccess = $oEncodedRk.Encode("url_rfc3986","utf-8")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

;  Escape apostrophes for OData first, then percent-encode each key once.
$oEntityPath = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oEntityPath.Append("/ExampleCustomers(PartitionKey='")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oEntityPath.Append($oEncodedPk.GetAsString())
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oEntityPath.Append("',RowKey='")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oEntityPath.Append($oEncodedRk.GetAsString())
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oEntityPath.Append("')")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$sResourcePath = $oEntityPath.GetAsString()
Local $iAttempt = 0
Local $iBaseDelayMs = 1000
Local $bFinished = False
$oTimer = ObjCreate("Chilkat.Http")
$oJitter = ObjCreate("Chilkat.Prng")
$oRetryText = ObjCreate("Chilkat.StringBuilder")
$oDigits = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oDigits.Append("0123456789")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$oRetryDate = ObjCreate("Chilkat.CkDateTime")
$oCurrentTime = ObjCreate("Chilkat.CkDateTime")
While ($bFinished <> True)
    $iAttempt = $iAttempt + 1
    $sResponseText = $oRest.FullRequestNoBody("GET",$sResourcePath)
    If ($oRest.LastMethodSuccess <> True) Then
        ConsoleWrite("Transport failure; this example does not retry incomplete reads." & @CRLF)
        Exit
    EndIf

Local $iHttpStatus = $oRest.ResponseStatusCode
    If ($iHttpStatus = 200) Then
        $bFinished = True
    Else
        If (($iHttpStatus <> 408) And ($iHttpStatus <> 429) And ($iHttpStatus <> 500) And ($iHttpStatus <> 502) And ($iHttpStatus <> 503) And ($iHttpStatus <> 504)) Then
            ConsoleWrite("Non-retryable HTTP status; inspect request ID privately." & @CRLF)
            Exit
        EndIf

        If ($iAttempt >= 5) Then
            ConsoleWrite("Retry limit reached." & @CRLF)
            Exit
        EndIf

Local $iDelayMs = $iBaseDelayMs + $oJitter.RandomInt(0,250)
        If ($oJitter.LastMethodSuccess <> True) Then
            ConsoleWrite("Could not generate retry jitter." & @CRLF)
            Exit
        EndIf

        $bSuccess = $oRetryText.SetString($oRest.ResponseHdrByName("Retry-After"))
        If ($bSuccess <> True) Then
            ConsoleWrite("Could not prepare the request." & @CRLF)
            Exit
        EndIf

        $bSuccess = $oRetryText.Trim()
        If ($bSuccess <> True) Then
            ConsoleWrite("Could not prepare the request." & @CRLF)
            Exit
        EndIf

        If ($oRetryText.Length > 0) Then
Local $bNumericDelay = True
Local $iDigitIndex = 0
            While ($iDigitIndex < $oRetryText.Length)
                If ($oDigits.Contains($oRetryText.GetRange($iDigitIndex,1,False),True) <> True) Then
                    $bNumericDelay = False
                EndIf

                $iDigitIndex = $iDigitIndex + 1
            Wend
Local $iRequestedSeconds = 0
            If ($bNumericDelay = True) Then
                If ($oRetryText.Length > 2) Then
                    ConsoleWrite("Retry-After exceeds this example wait budget." & @CRLF)
                    Exit
                EndIf

                $iRequestedSeconds = $oRetryText.IntValue
            Else
                $bSuccess = $oRetryDate.SetFromRfc822($oRetryText.GetAsString())
                If ($bSuccess <> True) Then
                    ConsoleWrite("Invalid Retry-After date." & @CRLF)
                    Exit
                EndIf

                $bSuccess = $oCurrentTime.SetFromCurrentSystemTime()
                If ($bSuccess <> True) Then
                    ConsoleWrite("Could not prepare the request." & @CRLF)
                    Exit
                EndIf

                $iRequestedSeconds = $oRetryDate.DiffSeconds($oCurrentTime) + 1
            EndIf

            If ($iRequestedSeconds > 30) Then
                ConsoleWrite("Server requested a longer wait; stop instead of retrying too soon." & @CRLF)
                Exit
            EndIf

            If ($iRequestedSeconds < 0) Then
                $iRequestedSeconds = 0
            EndIf

            If ($iRequestedSeconds * 1000 > $iDelayMs) Then
                $iDelayMs = $iRequestedSeconds * 1000
            EndIf

        EndIf

        ;  Retry only this GET; never copy this loop blindly to mutation requests.
        $oTimer.SleepMs $iDelayMs
        $iBaseDelayMs = $iBaseDelayMs * 2
        $oRest.Disconnect(10)
        $bSuccess = $oConnection.Connect($oEndpoint.GetAsString(),443,True,20000)
        If ($bSuccess <> True) Then
            ConsoleWrite("TLS reconnection failed." & @CRLF)
            Exit
        EndIf

        $bSuccess = $oRest.UseConnection($oConnection,False)
        If ($bSuccess <> True) Then
            ConsoleWrite("Could not prepare the request." & @CRLF)
            Exit
        EndIf

    EndIf

Wend
$bSuccess = $oResult.Load($sResponseText)
If ($bSuccess <> True) Then
    ConsoleWrite("Expected well-formed JSON." & @CRLF)
    Exit
EndIf

$oTextCompare.Clear 
$oTextCompare.SetString($oResult.StringOf("PartitionKey"))
Local $bSameText3 = $oTextCompare.ContentsEqual("",True)
If (($oResult.JsonTypeOf("PartitionKey") <> 1) Or ($bSameText3 = True)) Then
    ConsoleWrite("Missing string PartitionKey." & @CRLF)
    Exit
EndIf

$oTextCompare.Clear 
$oTextCompare.SetString($oResult.StringOf("RowKey"))
Local $bSameText4 = $oTextCompare.ContentsEqual("",True)
If (($oResult.JsonTypeOf("RowKey") <> 1) Or ($bSameText4 = True)) Then
    ConsoleWrite("Missing string RowKey." & @CRLF)
    Exit
EndIf

$oTextCompare.Clear 
$oTextCompare.SetString($oResult.StringOf("PartitionKey"))
Local $bSameText5 = $oTextCompare.ContentsEqual($sPartitionKey,True)
$oTextCompare.Clear 
$oTextCompare.SetString($oResult.StringOf("RowKey"))
Local $bSameText6 = $oTextCompare.ContentsEqual($sRowKey,True)
If (($bSameText5 <> True) Or ($bSameText6 <> True)) Then
    ConsoleWrite("Returned entity keys do not match." & @CRLF)
    Exit
EndIf

ConsoleWrite("Entity read completed with bounded retries." & @CRLF)