1

is there any simple way to copy data within Azure ADLS gen2 using Azure CLI, Rest API or Python?

Azure ADLS gen2 API documentation is very limited for now... https://learn.microsoft.com/en-us/rest/api/storageservices/data-lake-storage-gen2

1
  • Having same issue here Commented May 19, 2020 at 19:06

1 Answer 1

0

According to my research, we can use Azure CLI or python to move a directory or move a file. For more details, please refer to the document.

For example

  1. Install the storage CLI extension. Please note that the CLI version should be larger than 2.0.67
az extension add -n storage-preview
  1. Script
# move directory
az storage blob directory move -c my-file-system -d my-new-directory -s my-directory --account-name mystorageaccount

# move a file
az storage blob move -c my-file-system -d my-file-new.txt -s my-file.txt --account-name mystorageaccount

Python

try:

       file_system_client = service_client.get_file_system_client(file_system="my-file-system")
       directory_client = file_system_client.get_directory_client("my-directory")

       new_dir_name = "my-directory-renamed"
       directory_client.rename_directory(rename_destination=directory_client.file_system_name + '/' + new_dir_name)

    except Exception as e:
     print(e) 
Sign up to request clarification or add additional context in comments.

9 Comments

Thanks, what library do you use in your python example?
@fuggy_yama Regarding python sdk, please refer to learn.microsoft.com/en-us/azure/storage/blobs/…
@fuggy_yama Do you have any other concerns?
@fuggy_yamaf since you have no other concerns, could you please accept the answer. It may help more people.
I just realized that it is MOVE operation and I actuall need COPY files within ADLS gen2.
|

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.