You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Azure客户端下载Parquet格式的目录式文件?

解决Azure CLI下载Parquet文件/目录报错的方法

问题本质

你使用的az storage fs file download仅适用于单个文件下载,且旧版本Azure CLI对Parquet这类非常规文本格式的文件存在序列化策略兼容问题,才会触发ValueError: This pipeline didn't have the RawDeserializer policy; can't deserialize错误。

具体解决办法

  • 改用目录专用下载命令
    下载目录必须使用az storage fs directory download命令,而非针对单个文件的file download。修正后的命令示例:

    az storage fs directory download 
       --path myname/1/batch-repo/form/Fulfillment/2022/01/02/batch-form-Fulfillment.parquet/  
       --account-name my-storage-account --file-system my-container --recursive
    

    注意:添加--recursive参数确保下载目录下所有嵌套文件。

  • 升级Azure CLI到最新版本
    旧版本CLI的序列化逻辑存在缺陷,升级到最新版可修复这类兼容性问题。执行以下命令完成升级:

    az upgrade
    
  • 单个Parquet文件下载的临时规避方案
    如果下载单个Parquet文件仍报错,可添加--output none参数跳过CLI的序列化处理,示例:

    az storage fs file download 
       --path myname/1/batch-repo/form/Fulfillment/2022/01/02/batch-form-Fulfillment.parquet/single-file.parquet  
       --account-name my-storage-account --file-system my-container --output none
    
  • Python SDK手动下载(复杂场景备选)
    若CLI始终无法解决,可借助Azure Storage Data Lake Python SDK编写脚本完成下载:

    from azure.storage.filedatalake import DataLakeServiceClient
    import os
    
    # 初始化客户端
    service_client = DataLakeServiceClient(
        account_url="https://my-storage-account.dfs.core.windows.net/",
        credential="你的存储账户密钥"
    )
    file_system_client = service_client.get_file_system_client(file_system="my-container")
    directory_client = file_system_client.get_directory_client(
        "myname/1/batch-repo/form/Fulfillment/2022/01/02/batch-form-Fulfillment.parquet/"
    )
    
    # 递归下载目录下所有文件
    def download_dir(directory_client, local_root):
        os.makedirs(local_root, exist_ok=True)
        for path_item in directory_client.get_paths():
            if path_item.is_file:
                file_client = directory_client.get_file_client(path_item.name)
                local_file_path = os.path.join(local_root, path_item.name)
                with open(local_file_path, "wb") as f:
                    download_stream = file_client.download_file()
                    download_stream.readinto(f)
    
    download_dir(directory_client, "./本地保存路径")
    

内容的提问来源于stack exchange,提问作者WestCoastProjects

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 15:03:20