python - 使用 Azure CLI、Rest API 或 Python 在 Azure ADLS gen2 中复制文件

标签 python azure azure-data-lake-gen2

是否有任何简单的方法可以使用 Azure CLI、Rest API 或 Python 在 Azure ADLS gen2 中复制数据?

Azure ADLS gen2 API 文档目前非常有限... https://learn.microsoft.com/en-us/rest/api/storageservices/data-lake-storage-gen2

最佳答案

根据我的研究,我们可以使用Azure CLI或python来移动目录或移动文件。更多详情请引用document

例如

  1. 安装存储 CLI 扩展。请注意CLI版本应大于2.0.67
az extension add -n storage-preview
  • 脚本
  • # 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) 
    

    关于python - 使用 Azure CLI、Rest API 或 Python 在 Azure ADLS gen2 中复制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59823487/

    相关文章:

    python - 子类化 listview 以将多个 View 引用到一个模板 django

    mysql - 与 Azure 云数据库系统同步

    azure - 如何列出 Azure 数据湖第 2 代中按 Azure 数据工厂中的上次修改日期筛选的所有路径?

    c# - 使用 C# Azure.Storage.Files.DataLake 下载数据湖 blob(最好是并行)

    python - pygtk 在 Windows XP 中崩溃

    python - 使用 FileHandler 的 Django 日志记录不起作用

    python - Django 不上传图片

    c# - WebJob 控制台应用程序中的 ProcessQueueMessage 函数

    azure - 如何在数据流表达式生成器中连接字符串与日期

    Python:从 ADLS 文件夹中查找重命名并移动 JSON 文件