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

Azure Blob: List Versions and Recover Deleted Content

See more Azure Cloud Storage Examples

For a flat-namespace account, list the versions, snapshots and soft-deleted entries for one blob. Keep version IDs and snapshot timestamps as strings. The default action only lists choices; change action deliberately to undelete, restore-version or restore-snapshot and supply the selected ID.

Undelete recovers eligible soft-deleted content within its retention period. When versioning is enabled, undelete does not automatically make an older version the current base blob: restore the selected live version by copying it to the base name. A deleted snapshot/version may first require undelete. Restoring over an existing base requires its current quoted ETag; otherwise this example only creates an absent base. Retention expiration, permanent deletion and immutability policies can prevent recovery. Hierarchical-namespace accounts use a different recovery workflow with deletion IDs.

Uses direct Chilkat.Rest requests and Azure public-cloud endpoints with verified HTTPS. REST requests select service version 2026-04-06. Create local input/output directories before running. Account-key examples read account and access_key string fields from private qa_data/azure/storage.json; do not embed secrets in distributed applications. Entra examples explain their own configuration. Keep credentials, bearer tokens, SAS URLs and diagnostic dumps private. Shared Key is supported only where allowed by account policy; Entra authentication is preferred where available.

Transport success and HTTP status are checked separately. Writes are not automatically replayed after an uncertain response. IDs, ETags, continuation markers and file sizes are strings; counters and explicitly bounded offsets use int. No webhook or web server is required.

Microsoft reference.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoTextCompare
    Handle hoConfig
    Boolean iSameText1
    Boolean iSameText2
    Handle hoEndpoint
    String sResourcePath
    Handle hoRest
    Variant vAzAuth
    Handle hoAzAuth
    Variant vConnection
    Handle hoConnection
    String sResponseText
    Handle hoResult
    String sAction
    String sSelectedId
    String sDestinationEtag
    Handle hoSeenMarkers
    String sMarker
    Boolean iMore
    Integer iPage
    Integer iCount
    Integer i
    Boolean iSameText3
    Boolean iSameText4
    Boolean iSameText5
    Boolean iSameText6
    Boolean iSameText7
    Boolean iSameText8
    Boolean iSameText9
    Handle hoEncodedId
oreUrl    Handle hoRestoreUrl
    Boolean iSameText10
    Boolean iSameText11
    String sCopyId
    Boolean iSameText12
    Integer iPolls
    Boolean iCompleted
    Boolean iSameText13
    String sCopyStatus
    Boolean iSameText14
    Boolean iSameText15
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    Move False To iSuccess

    //  StringBuilder compares text by value in every generated language.
    Get Create (RefClass(cComChilkatStringBuilder)) To hoTextCompare
    If (Not(IsComObjectCreated(hoTextCompare))) Begin
        Send CreateComObject of hoTextCompare
    End
    //  Assumes Chilkat is unlocked. See Global Unlock Sample.
    Move False To iSuccess
    Get Create (RefClass(cComChilkatJsonObject)) To hoConfig
    If (Not(IsComObjectCreated(hoConfig))) Begin
        Send CreateComObject of hoConfig
    End
    Set ComStrict Of hoConfig To True
    Get ComLoadFile Of hoConfig "qa_data/azure/storage.json" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not load private Azure configuration."
        Procedure_Return
    End

    Send ComClear To hoTextCompare
    Get ComStringOf Of hoConfig "account" To sTemp1
    Get ComSetString Of hoTextCompare sTemp1 To iSuccess
    Get ComContentsEqual Of hoTextCompare "" True To iSameText1
    Get ComJsonTypeOf Of hoConfig "account" To iTemp1
    If ((iTemp1 <> 1) Or (iSameText1 = True)) Begin
        Showln "Supply the storage account name."
        Procedure_Return
    End

    //  access_key is the base64 account key, not a connection string or SAS.
    Send ComClear To hoTextCompare
    Get ComStringOf Of hoConfig "access_key" To sTemp1
    Get ComSetString Of hoTextCompare sTemp1 To iSuccess
    Get ComContentsEqual Of hoTextCompare "" True To iSameText2
    Get ComJsonTypeOf Of hoConfig "access_key" To iTemp1
    If ((iTemp1 <> 1) Or (iSameText2 = True)) Begin
        Showln "Supply the base64 account access key."
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoEndpoint
    If (Not(IsComObjectCreated(hoEndpoint))) Begin
        Send CreateComObject of hoEndpoint
    End
    Get ComStringOf Of hoConfig "account" To sTemp1
    Get ComAppend Of hoEndpoint sTemp1 To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    Get ComAppend Of hoEndpoint ".blob.core.windows.net" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    //  resourcePath is already URL-encoded. Encode each path segment once when adapting it.
    //  Keep slash separators; names and paths are case-sensitive.
    Move "/examplecontainer" To sResourcePath
    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End
    Set ComConnectTimeoutMs Of hoRest To 20000
    Set ComIdleTimeoutMs Of hoRest To 60000
    Get Create (RefClass(cComChilkatAuthAzureStorage)) To hoAzAuth
    If (Not(IsComObjectCreated(hoAzAuth))) Begin
        Send CreateComObject of hoAzAuth
    End
    Get ComStringOf Of hoConfig "account" To sTemp1
    Set ComAccount Of hoAzAuth To sTemp1
    Get ComStringOf Of hoConfig "access_key" To sTemp1
    Set ComAccessKey Of hoAzAuth To sTemp1
    Set ComService Of hoAzAuth To "Blob"
    Set ComScheme Of hoAzAuth To "SharedKey"
    Set ComXMsVersion Of hoAzAuth To "2026-04-06"
    Get pvComObject of hoAzAuth to vAzAuth
    Get ComSetAuthAzureStorage Of hoRest vAzAuth To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not configure Shared Key signing."
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatSocket)) To hoConnection
    If (Not(IsComObjectCreated(hoConnection))) Begin
        Send CreateComObject of hoConnection
    End
    Set ComRequireSslCertVerify Of hoConnection To True
    Set ComMaxReadIdleMs Of hoConnection To 60000
    Set ComMaxSendIdleMs Of hoConnection To 60000
    Get ComGetAsString Of hoEndpoint To sTemp1
    Get ComConnect Of hoConnection sTemp1 443 True 20000 To iSuccess
    If (iSuccess <> True) Begin
        Showln "TLS connection failed; inspect diagnostics privately."
        Procedure_Return
    End

    //  Do not replay a write automatically after losing its response.
    Get pvComObject of hoConnection to vConnection
    Get ComUseConnection Of hoRest vConnection False To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatXml)) To hoResult
    If (Not(IsComObjectCreated(hoResult))) Begin
        Send CreateComObject of hoResult
    End
    Set ComStrict Of hoResult To True
    //  Flat-namespace Blob account. Default is inspection only.
    //  Choose list, undelete, restore-version, or restore-snapshot.
    Move "list" To sAction
    Move "" To sSelectedId
    //  For restoring over an existing base blob, supply its current quoted ETag.
    //  Empty means restore only when the base blob is absent.
    Move "" To sDestinationEtag
    Get ComAddQueryParam Of hoRest "restype" "container" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    Get ComAddQueryParam Of hoRest "comp" "list" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    Get ComAddQueryParam Of hoRest "prefix" "example.bin" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    Get ComAddQueryParam Of hoRest "include" "versions,snapshots,deleted,deletedwithversions" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    Get ComAddQueryParam Of hoRest "maxresults" "1000" To iSuccess
    If (iSuccess <> True) Begin
        Showln "Could not prepare the request."
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatHashtable)) To hoSeenMarkers
    If (Not(IsComObjectCreated(hoSeenMarkers))) Begin
        Send CreateComObject of hoSeenMarkers
    End
    Move "" To sMarker
    Move True To iMore
    Move 0 To iPage
    While (iMore = True)
        If (iPage >= 1000) Begin
            Showln "Page limit reached; results are incomplete. Save the continuation marker."
            Procedure_Return
        End

        Get ComFullRequestNoBody Of hoRest "GET" sResourcePath To sResponseText
        Get ComLastMethodSuccess Of hoRest To bTemp1
        If (bTemp1 <> True) Begin
            Showln "Request did not complete; outcome may be uncertain."
            Procedure_Return
        End

        Get ComResponseStatusCode Of hoRest To iTemp1
        If (iTemp1 <> 200) Begin
            Get ComResponseStatusCode Of hoRest To iTemp1
            Showln "HTTP status: " iTemp1
            Get ComResponseHdrByName Of hoRest "x-ms-error-code" To sTemp1
            Showln "Azure error code: " sTemp1
            Get ComResponseHdrByName Of hoRest "x-ms-request-id" To sTemp1
            Showln "Request ID: " sTemp1
            //  Inspect any error body privately; do not log credentials, SAS URLs or payloads.
            Procedure_Return
        End

        Get ComLoadXml Of hoResult sResponseText To iSuccess
        If (iSuccess <> True) Begin
            Showln "Expected well-formed XML."
            Procedure_Return
        End

        Get ComTagEquals Of hoResult "EnumerationResults" To bTemp1
        If (bTemp1 <> True) Begin
            Showln "Unexpected XML response root."
            Procedure_Return
        End

        Get ComNumChildrenAt Of hoResult "Blobs" To iCount
        Move 0 To i
        While (i < iCount)
            Set ComI Of hoResult To i
            Send ComClear To hoTextCompare
            Get ComGetChildContent Of hoResult "Blobs|Blob[i]|Name" To sTemp1
            Get ComSetString Of hoTextCompare sTemp1 To iSuccess
            Get ComContentsEqual Of hoTextCompare "example.bin" True To iSameText3
            If (iSameText3 = True) Begin
                Get ComGetChildContent Of hoResult "Blobs|Blob[i]|VersionId" To sTemp1
                Showln "Version ID: " sTemp1
                Get ComGetChildContent Of hoResult "Blobs|Blob[i]|Snapshot" To sTemp1
                Showln "Snapshot: " sTemp1
                Get ComGetChildContent Of hoResult "Blobs|Blob[i]|Deleted" To sTemp1
                Showln "Deleted: " sTemp1
                Get ComGetChildContent Of hoResult "Blobs|Blob[i]|IsCurrentVersion" To sTemp1
                Showln "Current version: " sTemp1
                Get ComGetChildContent Of hoResult "Blobs|Blob[i]|HasVersionsOnly" To sTemp1
                Showln "Has versions only: " sTemp1
            End

            Move (i + 1) To i
        Loop

        Get ComGetChildContent Of hoResult "NextMarker" To sMarker
        Move (iPage + 1) To iPage
        Send ComClear To hoTextCompare
        Get ComSetString Of hoTextCompare sMarker To iSuccess
        Get ComContentsEqual Of hoTextCompare "" True To iSameText4
        If (iSameText4 = True) Begin
            Move False To iMore
        End
        Else Begin
            Get ComContains Of hoSeenMarkers sMarker To bTemp1
            If (bTemp1 = True) Begin
                Showln "Repeated marker; results are incomplete."
                Procedure_Return
            End

            Get ComAddInt Of hoSeenMarkers sMarker 1 To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            If (iPage > 1) Begin
                Get ComRemoveQueryParam Of hoRest "marker" To iSuccess
                If (iSuccess <> True) Begin
                    Showln "Could not prepare the request."
                    Procedure_Return
                End

            End

            Get ComAddQueryParam Of hoRest "marker" sMarker To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComDisconnect Of hoRest 10 To iSuccess
            Get ComGetAsString Of hoEndpoint To sTemp1
            Get ComConnect Of hoConnection sTemp1 443 True 20000 To iSuccess
            If (iSuccess <> True) Begin
                Showln "TLS reconnection failed."
                Procedure_Return
            End

            Get pvComObject of hoConnection to vConnection
            Get ComUseConnection Of hoRest vConnection False To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

        End

    Loop

    Send ComClear To hoTextCompare
    Get ComSetString Of hoTextCompare sAction To iSuccess
    Get ComContentsEqual Of hoTextCompare "list" True To iSameText5
    If (iSameText5 <> True) Begin
        Get ComClearAllQueryParams Of hoRest To iSuccess
        If (iSuccess <> True) Begin
            Showln "Could not prepare the request."
            Procedure_Return
        End

        Move "/examplecontainer/example.bin" To sResourcePath
        Send ComClear To hoTextCompare
        Get ComSetString Of hoTextCompare sAction To iSuccess
        Get ComContentsEqual Of hoTextCompare "undelete" True To iSameText6
        If (iSameText6 = True) Begin
            Get ComAddQueryParam Of hoRest "comp" "undelete" To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComDisconnect Of hoRest 10 To iSuccess
            Get ComGetAsString Of hoEndpoint To sTemp1
            Get ComConnect Of hoConnection sTemp1 443 True 20000 To iSuccess
            If (iSuccess <> True) Begin
                Showln "TLS reconnection failed."
                Procedure_Return
            End

            Get pvComObject of hoConnection to vConnection
            Get ComUseConnection Of hoRest vConnection False To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComFullRequestNoBody Of hoRest "PUT" sResourcePath To sResponseText
            Get ComLastMethodSuccess Of hoRest To bTemp1
            If (bTemp1 <> True) Begin
                Showln "Request did not complete; outcome may be uncertain."
                Procedure_Return
            End

            Get ComResponseStatusCode Of hoRest To iTemp1
            If (iTemp1 <> 200) Begin
                Get ComResponseStatusCode Of hoRest To iTemp1
                Showln "HTTP status: " iTemp1
                Get ComResponseHdrByName Of hoRest "x-ms-error-code" To sTemp1
                Showln "Azure error code: " sTemp1
                Get ComResponseHdrByName Of hoRest "x-ms-request-id" To sTemp1
                Showln "Request ID: " sTemp1
                //  Inspect any error body privately; do not log credentials, SAS URLs or payloads.
                Procedure_Return
            End

            Showln "Undelete accepted. Rerun listing before selecting a version or snapshot."
        End
        Else Begin
            Send ComClear To hoTextCompare
            Get ComSetString Of hoTextCompare sAction To iSuccess
            Get ComContentsEqual Of hoTextCompare "restore-version" True To iSameText7
            Send ComClear To hoTextCompare
            Get ComSetString Of hoTextCompare sAction To iSuccess
            Get ComContentsEqual Of hoTextCompare "restore-snapshot" True To iSameText8
            If ((iSameText7 <> True) And (iSameText8 <> True)) Begin
                Showln "Unknown recovery action."
                Procedure_Return
            End

            Send ComClear To hoTextCompare
            Get ComSetString Of hoTextCompare sSelectedId To iSuccess
            Get ComContentsEqual Of hoTextCompare "" True To iSameText9
            If (iSameText9 = True) Begin
                Showln "Select a version or snapshot ID from the listing first."
                Procedure_Return
            End

            Get Create (RefClass(cComChilkatStringBuilder)) To hoEncodedId
            If (Not(IsComObjectCreated(hoEncodedId))) Begin
                Send CreateComObject of hoEncodedId
            End
            Get ComAppend Of hoEncodedId sSelectedId To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComEncode Of hoEncodedId "url" "utf-8" To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get Create (RefClass(cComChilkatStringBuilder)) To hoRestoreUrl
            If (Not(IsComObjectCreated(hoRestoreUrl))) Begin
                Send CreateComObject of hoRestoreUrl
            End
            Get ComAppend Of hoRestoreUrl "https://" To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComGetAsString Of hoEndpoint To sTemp1
            Get ComAppend Of hoRestoreUrl sTemp1 To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComAppend Of hoRestoreUrl sResourcePath To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Send ComClear To hoTextCompare
            Get ComSetString Of hoTextCompare sAction To iSuccess
            Get ComContentsEqual Of hoTextCompare "restore-version" True To iSameText10
            If (iSameText10 = True) Begin
                Get ComAppend Of hoRestoreUrl "?versionid=" To iSuccess
                If (iSuccess <> True) Begin
                    Showln "Could not prepare the request."
                    Procedure_Return
                End

            End
            Else Begin
                Get ComAppend Of hoRestoreUrl "?snapshot=" To iSuccess
                If (iSuccess <> True) Begin
                    Showln "Could not prepare the request."
                    Procedure_Return
                End

            End

            Get ComGetAsString Of hoEncodedId To sTemp1
            Get ComAppend Of hoRestoreUrl sTemp1 To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComGetAsString Of hoRestoreUrl To sTemp1
            Get ComAddHeader Of hoRest "x-ms-copy-source" sTemp1 To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Send ComClear To hoTextCompare
            Get ComSetString Of hoTextCompare sDestinationEtag To iSuccess
            Get ComContentsEqual Of hoTextCompare "" True To iSameText11
            If (iSameText11 = True) Begin
                Get ComAddHeader Of hoRest "If-None-Match" "*" To iSuccess
                If (iSuccess <> True) Begin
                    Showln "Could not prepare the request."
                    Procedure_Return
                End

            End
            Else Begin
                Get ComAddHeader Of hoRest "If-Match" sDestinationEtag To iSuccess
                If (iSuccess <> True) Begin
                    Showln "Could not prepare the request."
                    Procedure_Return
                End

            End

            Get ComDisconnect Of hoRest 10 To iSuccess
            Get ComGetAsString Of hoEndpoint To sTemp1
            Get ComConnect Of hoConnection sTemp1 443 True 20000 To iSuccess
            If (iSuccess <> True) Begin
                Showln "TLS reconnection failed."
                Procedure_Return
            End

            Get pvComObject of hoConnection to vConnection
            Get ComUseConnection Of hoRest vConnection False To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComFullRequestNoBody Of hoRest "PUT" sResourcePath To sResponseText
            Get ComLastMethodSuccess Of hoRest To bTemp1
            If (bTemp1 <> True) Begin
                Showln "Request did not complete; outcome may be uncertain."
                Procedure_Return
            End

            Get ComResponseStatusCode Of hoRest To iTemp1
            If (iTemp1 <> 202) Begin
                Get ComResponseStatusCode Of hoRest To iTemp1
                Showln "HTTP status: " iTemp1
                Get ComResponseHdrByName Of hoRest "x-ms-error-code" To sTemp1
                Showln "Azure error code: " sTemp1
                Get ComResponseHdrByName Of hoRest "x-ms-request-id" To sTemp1
                Showln "Request ID: " sTemp1
                //  Inspect any error body privately; do not log credentials, SAS URLs or payloads.
                Procedure_Return
            End

            Get ComResponseHdrByName Of hoRest "x-ms-copy-id" To sCopyId
            Send ComClear To hoTextCompare
            Get ComSetString Of hoTextCompare sCopyId To iSuccess
            Get ComContentsEqual Of hoTextCompare "" True To iSameText12
            If (iSameText12 = True) Begin
                Showln "Copy accepted without a copy ID; inspect before retrying."
                Procedure_Return
            End

            Showln "Copy ID: " sCopyId
            //  Save copyId and destination in application state if polling must survive restart.
            Get ComClearAllHeaders Of hoRest To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Get ComClearAllQueryParams Of hoRest To iSuccess
            If (iSuccess <> True) Begin
                Showln "Could not prepare the request."
                Procedure_Return
            End

            Move 0 To iPolls
            Move False To iCompleted
            While ((iPolls < 20) And (iCompleted <> True))
                Get ComDisconnect Of hoRest 10 To iSuccess
                Get ComGetAsString Of hoEndpoint To sTemp1
                Get ComConnect Of hoConnection sTemp1 443 True 20000 To iSuccess
                If (iSuccess <> True) Begin
                    Showln "TLS reconnection failed."
                    Procedure_Return
                End

                Get pvComObject of hoConnection to vConnection
                Get ComUseConnection Of hoRest vConnection False To iSuccess
                If (iSuccess <> True) Begin
                    Showln "Could not prepare the request."
                    Procedure_Return
                End

                Get ComFullRequestNoBody Of hoRest "HEAD" sResourcePath To sResponseText
                Get ComLastMethodSuccess Of hoRest To bTemp1
                If (bTemp1 <> True) Begin
                    Showln "Request did not complete; outcome may be uncertain."
                    Procedure_Return
                End

                Get ComResponseStatusCode Of hoRest To iTemp1
                If (iTemp1 <> 200) Begin
                    Get ComResponseStatusCode Of hoRest To iTemp1
                    Showln "HTTP status: " iTemp1
                    Get ComResponseHdrByName Of hoRest "x-ms-error-code" To sTemp1
                    Showln "Azure error code: " sTemp1
                    Get ComResponseHdrByName Of hoRest "x-ms-request-id" To sTemp1
                    Showln "Request ID: " sTemp1
                    //  Inspect any error body privately; do not log credentials, SAS URLs or payloads.
                    Procedure_Return
                End

                Send ComClear To hoTextCompare
                Get ComResponseHdrByName Of hoRest "x-ms-copy-id" To sTemp1
                Get ComSetString Of hoTextCompare sTemp1 To iSuccess
                Get ComContentsEqual Of hoTextCompare sCopyId True To iSameText13
                If (iSameText13 <> True) Begin
                    Showln "Destination no longer reports this copy ID."
                    Procedure_Return
                End

                Get ComResponseHdrByName Of hoRest "x-ms-copy-status" To sCopyStatus
                Send ComClear To hoTextCompare
                Get ComSetString Of hoTextCompare sCopyStatus To iSuccess
                Get ComContentsEqual Of hoTextCompare "success" True To iSameText14
                If (iSameText14 = True) Begin
                    Move True To iCompleted
                End
                Else Begin
                    Send ComClear To hoTextCompare
                    Get ComSetString Of hoTextCompare sCopyStatus To iSuccess
                    Get ComContentsEqual Of hoTextCompare "pending" True To iSameText15
                    If (iSameText15 <> True) Begin
                        Showln "Copy failed, was aborted, or returned an unexpected status; inspect copy diagnostics privately."
                        Procedure_Return
                    End

                    //  Pause between polls; the copy can outlast this example's bounded wait.
                    Send ComSleepMs To hoConnection 1000
                End

                Move (iPolls + 1) To iPolls
            Loop

            If (iCompleted <> True) Begin
                Showln "Copy is still pending. Continue polling this ID; do not start another copy."
                Procedure_Return
            End

            Showln "Copy completed."
        End

    End

    Showln "Recovery workflow finished."


End_Procedure