0

I'm tryng to copy a blob from one container to a subfolder in the same container but i have been unable to do so. I'm using Python Azure SDK 12 and using the example provided here and in many other places as base https://stackoverflow.com/a/64285413

    blob_service_client = BlobServiceClient.from_connection_string(blob_connection_str)
    container_client = blob_service_client.get_container_client("mycontainer")
    source_blob = container_client.get_blob_client("mycontainer", "myblob.txt")
    destination_blob = container_client.get_blob_client("mycontainer", "subfolder/myblob.txt")

    destination_blob.start_copy_from_url(source_blob.url)

However when i ran the last line it'd fail saying that snapshot is an invalid queryParam, and i printed out souce_blob.url and it was indeed not the url i would have expected

https://myaccount.blob.core.windows.net/mycontainer/mycontainer?snapshot=/mycontainer/subfolder/myblob.txt

So I tried constructing the url myself manually as in this example, this URL is the exact same URL i get when i go to Azure portal to get the URL for the blob: https://stackoverflow.com/a/62401832

    source_blob = (f"https://myaccountname.blob.core.windows.net/mycontainer/subfolder/myblob.txt")
    destination_blob.start_copy_from_url(source_blob)

but for some reason i still get the same snapshot error, i don't understand why start_copy_from_url is passing the blob name as a snapshot param? i'm very confused by that

ErrorCode:InvalidQueryParameterValue Error:None QueryParameterName:snapshot QueryParameterValue:mycontainer/subfolder/myblob.txt

Any ideas what i'm doing wrong or how to bypass this?

0

1 Answer 1

2

Not familiar with Python but once you are specifying the container name mycontainer in line nr 2, why do you specify it again in lines 3 and 4? Check it here get_blob_client for Python

The code should be(lines 3 and 4)

source_blob = container_client.get_blob_client("myblob.txt")
destination_blob = container_client.get_blob_client("subfolder/myblob.txt")
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the response. It's because it's two different clients, however i did change the code as suggested but still getting same error, no difference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.