0

I am using Microsoft Azure SDK for Python in project. I want to copy data from snapshot to disk. For this task I am using readable SASuri of Snapshot and writable SASuri of Disk.

Here is the example I am using to transfer data.

blob_client = BlobClient.from_blob_url("https://<writable-SASUri-disk>")
copy_source_url = r"https://<readable-SASUri-snapshot>"
blob_client.start_copy_from_url(copy_source_url, metadata=None, incremental_copy=False,requires_sync=True)

And I am getting below error: enter image description here

Any idea how to resolve this issue?

Nilesh
  • 3
  • 2

1 Answers1

0

I tried the code below to copy my snapshot to disk using blob client copy url by using my SAS URLs, but received an error with limitation like below:-

Code:-

import asyncio
from azure.storage.blob import BlobClient

async def copy_snapshot_to_disk():
    # Create a BlobClient object for the writable SAS URI of the disk
    disk_client = BlobClient.from_blob_url("https://valleystrg.blob.core.windows.net/disk/abcd?sp=rw&st=2023-04-03T10:27:36Z&se=2023-04-03T18:27:36Z&spr=https&sv=2021-12-02&sr=b&sig=xxxxxxxxxxxxxxxxxxxxJtcei011QjEcoC7A%3D")
    # Create a BlobClient object for the readable SAS URI of the snapshot
    snapshot_client = BlobClient.from_blob_url("https://valleystrg.blob.core.windows.net/disk/abcd%20(1)?sp=r&st=2023-04-03T10:25:25Z&se=2023-04-03T18:25:25Z&spr=https&sv=2021-12-02&sr=b&sig=xxxxxtEQ3er2SSVWqshkiXJ8CEpn7s68O%2FOjm0%3D")

    # Start the copy operation from the snapshot to the disk
    headers = {"x-ms-copy-source": snapshot_client.url, "x-ms-copy-type": "blob"}
    copy_id = await disk_client.start_copy_from_url(snapshot_client.url, headers=headers, metadata=None, incremental_copy=False, requires_sync=True)

    # Wait for the copy operation to complete
    while True:
        properties = await disk_client.get_blob_properties()
        if properties.copy.status == "success":
            break
        await asyncio.sleep(1)

    # Print the copy operation result
    print("Copy operation status: ", properties.copy.status)

async def main():
    await copy_snapshot_to_disk()

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Output:

azure.core.exceptions.ResourceExistsError: **The source request body for synchronous copy is too large and exceeds the maximum permissible limit (256MB).**
Time:2023-04-03T10:46:30.3838959Z
ErrorCode:CannotVerifyCopySource
Content: <?xml version="1.0" encoding="utf-8"?><Error><Code>CannotVerifyCopySource</Code><Message>The source request body for synchronous copy is too large and exceeds the maximum permissible limit (256MB).
Time:2023-04-03T10:46:30.3838959Z</Message></Error>

enter image description here

There's a limit of 256 MB using blob client copy url's to copy the data to destination path and Snapshot or Disks are of 1GB and greater size so using above method will not work.

As an alternative you can use az copy tool to copy your snapshot to disk like below:-

Command:

azcopy copy `"https://valleystrg.blob.core.windows.net/disk/abcd%20(1)?<SAS-Token>" "https://valleystrg.blob.core.windows.net/disk/abcd?<SAS-Token>" --recursive=true`

Output:

INFO: Scanning...
INFO: azcopy: A newer version 10.17.0 is available to download
INFO: Failed to create one or more destination container(s). Your transfers may still succeed if the container already exists.
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support
Job xxxxxxxx-ddb3dd4dc3ec has started
Log file is located at: /home/xxxx/.azcopy/xxxxxxc.log

100.0 %, 1 Done, 0 Failed, 0 Pending, 0 Skipped, 1 Total, 2-sec Throughput (Mb/s): 268.3198

Job xxxxx-ddb3dd4dc3ec summary
Elapsed Time (Minutes): 0.0667
Number of File Transfers: 1
Number of Folder Property Transfers: 0
Total Number of Transfers: 1
Number of Transfers Completed: 1
Number of Transfers Failed: 0
Number of Transfers Skipped: 0
TotalBytesTransferred: 1073742336
Final Job Status: Completed

enter image description here

Reference:-

az storage blob copy start fails when files are larger than 256MB and requires-sync=true - Microsoft Q&A

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11